Skip to main content

Clock

Trait Clock 

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

Injectable time source for mesh components.

§Production

Bind RealClock (or Arc::new(RealClock)).

§Tests

Bind MockClock and call MockClock::advance to drive timeouts without sleeping.

Required Methods§

Source

fn now(&self) -> MonoTime

Current monotonic time (for timeouts / TTL).

Source

fn unix_time_us(&self) -> u64

Wall-clock microseconds since Unix epoch (for mesh time sync).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§