Skip to main content

Clock

Trait Clock 

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

A source of time, injected into the Registry (FR-05).

The server passes a system clock; tests pass a FakeClock. Any Fn() -> Millis + Send + Sync closure is also a clock.

use hardless_core::{Clock, Millis};
let fixed = || Millis(42);
assert_eq!(fixed.now(), Millis(42));

Required Methods§

Source

fn now(&self) -> Millis

The current time.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Clock for FakeClock

Source§

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