suharev7 / clickhouse-rs

Asynchronous ClickHouse client library for Rust programming language.
MIT License
324 stars 121 forks source link

Support for Int256 and UInt256 #196

Open gusinacio opened 1 year ago

gusinacio commented 1 year ago

I'm planning to create a PR for uint256 and int256 but I would like some guidance related to the types.

Rust doesn't implement native i256 neither u256. Should this crate follow the example of klickhouse and implement its own types?

Should we use an external crate like primitive_types?

I'd suggest to create the own types and implement the From trait under a feature flag if needed. This way we don't rely on external crates that don't even implement i256, or have a lot more than needed in this crate.

gusinacio commented 1 year ago

ethnum may be one external_crate to use. It seems that it's a simple and direct implementation of u256 and i256 without any ethereum types or utils.

From their docs:

The implementation tries to follow as closely as possible to primitive integer types, and should implement all the common methods and traits as the primitive integer types.