Clock

Trait Clock 

Source
pub trait Clock:
    Send
    + Sync
    + Debug {
    // Required methods
    fn now(&self) -> Instant;
    fn system_time(&self) -> SystemTime;

    // Provided method
    fn since(&self, earlier: Instant) -> Duration { ... }
}
Expand description

A source of monotonic and wall-clock time.

Required Methods§

Source

fn now(&self) -> Instant

The current monotonic instant. Use for durations and deadlines.

Source

fn system_time(&self) -> SystemTime

The current wall-clock time. Use for timestamps that leave the process.

Provided Methods§

Source

fn since(&self, earlier: Instant) -> Duration

Time elapsed since earlier, per this clock. Saturates at zero.

Implementors§