pub trait TimeExt: Sized + Copy {
const ZERO: Self;
Show 14 methods
// Required methods
fn from_millis(millis: i64) -> Self;
fn from_micros(micros: i64) -> Self;
fn from_nanos(nanos: i64) -> Self;
fn from_secs(secs: i64) -> Self;
fn from_secs_f64(secs: f64) -> Self;
fn from_std(duration: Duration) -> Self;
fn millis_i32(self) -> i32;
fn millis_i64(self) -> i64;
fn millis_i64_trunc(self) -> i64;
fn micros_i64(self) -> i64;
fn nanos_i64(self) -> i64;
fn secs_i64(self) -> i64;
fn secs_f64(self) -> f64;
fn to_std(self) -> Duration;
}Expand description
Time extents: construction from raw integers and Duration, and extraction
back to them.
Required Associated Constants§
Required Methods§
Sourcefn from_millis(millis: i64) -> Self
fn from_millis(millis: i64) -> Self
A raw millisecond count. This is Kafka’s unit for every configured timeout, interval, and retention window.
Sourcefn from_micros(micros: i64) -> Self
fn from_micros(micros: i64) -> Self
A raw microsecond count.
Sourcefn from_nanos(nanos: i64) -> Self
fn from_nanos(nanos: i64) -> Self
A raw nanosecond count, for measured latencies.
Sourcefn from_secs_f64(secs: f64) -> Self
fn from_secs_f64(secs: f64) -> Self
A fractional second count.
Sourcefn from_std(duration: Duration) -> Self
fn from_std(duration: Duration) -> Self
A Duration, which is the unit tokio, std, and qubit-clock use.
Sourcefn millis_i32(self) -> i32
fn millis_i32(self) -> i32
The extent as Kafka’s int32 millisecond fields (session_timeout_ms).
Sourcefn millis_i64(self) -> i64
fn millis_i64(self) -> i64
The extent as Kafka’s int64 millisecond fields (retention_ms).
Sourcefn millis_i64_trunc(self) -> i64
fn millis_i64_trunc(self) -> i64
The extent in whole milliseconds, truncated toward zero.
Self::millis_i64 rounds to nearest, which is correct for a value that
a caller reads back as a duration. Use this function only to match an
external format that truncates. Tempo’s durationMs is its nanosecond
duration integer-divided by a million, so rounding would report one
millisecond more than Tempo does for the same span.
Sourcefn micros_i64(self) -> i64
fn micros_i64(self) -> i64
The extent in microseconds.
Sourcefn to_std(self) -> Duration
fn to_std(self) -> Duration
The extent as a Duration, for tokio::time::sleep and friends.
A negative or NaN extent becomes Duration::ZERO, because Duration
cannot represent it and every caller means “do not sleep”. A deadline that
has already passed gives such an extent.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".