Skip to main content

Clock

Trait Clock 

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

Supplies wall-clock time without making core services read the system clock.

Production runtimes can implement this trait with SystemTime::now, while tests use a fixed or manually advanced clock.

Required Methods§

Source

fn now(&self) -> SystemTime

Returns the current wall-clock time.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<F> Clock for F
where F: Fn() -> SystemTime + Send + Sync,