Skip to main content

Clock

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.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<C: Clock> Clock for &C

Source§

fn now(&self) -> SystemTime

Implementors§

Source§

impl Clock for FixedClock

Available on crate features test-dependencies only.
Source§

impl Clock for SystemClock