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§
Sourcefn now(&self) -> Instant
fn now(&self) -> Instant
Monotonic timestamp suitable for measuring durations between two reads.
Sourcefn delay(&self, dur: Duration) -> BoxedDelay
fn delay(&self, dur: Duration) -> BoxedDelay
Future that resolves after dur has elapsed in this clock’s frame.
Sourcefn duration_since_epoch(&self) -> Duration
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.