referrerpolicy=no-referrer-when-downgrade

Clock

Trait Clock 

Source
pub trait Clock: Send + Sync {
    // Required methods
    fn now(&self) -> Instant;
    fn delay(&self, dur: Duration) -> BoxedDelay;
    fn duration_since_epoch(&self) -> Duration;
}
Expand description

Abstraction over wall-clock time. See module-level docs.

Required Methods§

Source

fn now(&self) -> Instant

Monotonic timestamp suitable for measuring durations between two reads.

Source

fn delay(&self, dur: Duration) -> BoxedDelay

Future that resolves after dur has elapsed in this clock’s frame.

Source

fn duration_since_epoch(&self) -> Duration

Wall-clock duration since the UNIX epoch. Used for slot math and persistence timestamps; not monotonic. Callers pick a granularity (as_secs, as_millis) at the call site.

Implementors§