Skip to main content

Clock

Trait Clock 

Source
pub trait Clock:
    Send
    + Sync
    + 'static {
    // Required methods
    fn now_ms(&self) -> u64;
    fn after_ms(&self, delay_ms: u64, task: Box<dyn FnOnce() + Send>);
}
Expand description

Time source for providers that answer later. Scenarios inject a ManualClock to decide the order of completions.

Required Methods§

Source

fn now_ms(&self) -> u64

Milliseconds since the clock started.

Source

fn after_ms(&self, delay_ms: u64, task: Box<dyn FnOnce() + Send>)

Run task once delay_ms have passed, on a thread of the clock’s choosing.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§