Skip to main content

Clock

Trait Clock 

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

A source of the current time.

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

Required Methods§

Source

fn now(&self) -> OffsetDateTime

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() -> OffsetDateTime + Send + Sync + 'static,