Trait Clock

Source
pub trait Clock {
    // Required method
    fn now(&self) -> SystemTime;
}
Expand description

A trait that represents the capability to read the system time.

Using implementations of this trait instead of accessing the system clock directly allows mocking with a controlled clock for testing purposes.

Required Methods§

Source

fn now(&self) -> SystemTime

Returns the current system time, according to this clock.

Implementations on Foreign Types§

Source§

impl<C: Clock> Clock for &C

Source§

fn now(&self) -> SystemTime

Implementors§

Source§

impl Clock for SystemClock

Source§

impl Clock for FixedClock

Available on crate feature test-dependencies only.