Skip to main content

Clock

Trait Clock 

Source
pub trait Clock:
    Send
    + Sync
    + Debug {
    // Required method
    fn elapsed(&self) -> Duration;
}
Expand description

A monotonic clock, injectable so a refresh boundary is a test rather than a wait.

The production implementation is TokioClock, and it is tokio’s clock rather than std’s for a reason that is easy to get backwards: under a deterministic simulator the tokio clock is virtual and std::time::Instant is not, so a sixty-minute boundary crossed in simulated time is invisible to std. A client that timed its token against std::time::Instant would pass a seventy-minute simulation without ever re-minting.

Required Methods§

Source

fn elapsed(&self) -> Duration

Time since this clock was created.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§