pub trait Clock: Send + Sync {
// Required method
fn now(&self) -> Timestamp;
// Provided method
fn elapsed(&self) -> Duration { ... }
}Expand description
The instant core reads the current time from.
Shareable across threads, because the expiry driver reads it from a thread of its own while callers read it from theirs.
Required Methods§
Provided Methods§
Sourcefn elapsed(&self) -> Duration
fn elapsed(&self) -> Duration
How much time has passed since an origin of this clock’s own, on a clock nothing steps: two readings differ by the time that passed between them, whatever the wall clock did meanwhile.
The provided reading is Clock::now’s, as time since the Unix epoch,
which a step of the wall clock moves; a clock over a host’s own time
answers its monotonic clock instead, as SystemClock does.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".