Skip to main content

Clock

Trait Clock 

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

A source of the current time.

The guard never calls Utc::now directly, so tests (and simulations) can drive time with ManualClock. Any Fn() -> DateTime<Utc> closure is also a clock.

Required Methods§

Source

fn now(&self) -> DateTime<Utc>

The current instant.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Clock for ManualClock

Source§

impl Clock for SystemClock

Source§

impl<F> Clock for F
where F: Fn() -> DateTime<Utc> + Send + Sync + 'static,