Skip to main content

Clock

Trait Clock 

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

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

Trait for time operations, allowing testability.

Required Methods§

Source

fn now(&self) -> Instant

Get the current instant.

Provided Methods§

Source

fn elapsed(&self, start: Instant) -> Duration

Get a duration since the given instant.

Implementors§