referrerpolicy=no-referrer-when-downgrade

Module mock

Module mock 

Source
Expand description

Deterministic, fully-virtual Clock implementation for tests.

Virtualises all three time channels: now() (monotonic), delay() (driven by a wakeup queue rather than a real timer), and duration_since_epoch() (wall clock). Tests advance time explicitly via MockClock::advance / MockClock::advance_secs; pending Clock::delay futures resolve when their deadline is crossed.

let clock = Arc::new(MockClock::default());
let mut delay = clock.delay(Duration::from_millis(500));
clock.advance(Duration::from_millis(500)); // `delay` now resolves

Structs§

MockClock
A deterministic clock backed by manually-advanced inner state.