Skip to main content

TimeExt

Trait TimeExt 

Source
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§

Source

const ZERO: Self

No elapsed time.

Required Methods§

Source

fn from_millis(millis: i64) -> Self

A raw millisecond count. This is Kafka’s unit for every configured timeout, interval, and retention window.

Source

fn from_micros(micros: i64) -> Self

A raw microsecond count.

Source

fn from_nanos(nanos: i64) -> Self

A raw nanosecond count, for measured latencies.

Source

fn from_secs(secs: i64) -> Self

A raw second count.

Source

fn from_secs_f64(secs: f64) -> Self

A fractional second count.

Source

fn from_std(duration: Duration) -> Self

A Duration, which is the unit tokio, std, and qubit-clock use.

Source

fn millis_i32(self) -> i32

The extent as Kafka’s int32 millisecond fields (session_timeout_ms).

Source

fn millis_i64(self) -> i64

The extent as Kafka’s int64 millisecond fields (retention_ms).

Source

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.

Source

fn micros_i64(self) -> i64

The extent in microseconds.

Source

fn nanos_i64(self) -> i64

The extent in nanoseconds.

Source

fn secs_i64(self) -> i64

The extent in whole seconds, rounded to nearest.

Source

fn secs_f64(self) -> f64

The extent in fractional seconds, for metrics histograms.

Source

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".

Implementors§

Source§

impl TimeExt for Time

Source§

const ZERO: Self