influxdb-rs/influxdb-rust

Timestamp uses usize (dependent on architecture)

mario-kr opened this issue · 2 comments

The Timestamp-Enum (or rather, its variants) all use usize. The size of usize is dependent on the architecture of the running host, so people running 32-bit systems[1] will have trouble with any number bigger than 2^32, which, in this case, limits them to an accuracy of seconds.

As InfluxDB supports up to nanosecond-accuracy, at the very least u64 should be used.

std::time::Duration::as_nanos as well as tokio::time::Duration::as_nanos even return an u128.

The change would not be big, and would eliminate any and all risks of panics when converting/casting numbers.

[1] tbh, the only use-case where i can see 32-bit and influx overlapping is in IoT-monitoring

Thanks for raising this. This is definitely an oversight and should be fixed to support all accuracies InfluxDb also offers. Feel free to open a PR with fixes.

Closed in #50