Skip to main content

Clock

Trait Clock 

Source
pub trait Clock: Send + Sync {
    // Required methods
    fn now(&self) -> Duration;
    fn sleep(
        &self,
        duration: Duration,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'static>>;
}
Expand description

A source of monotonic time and of waits measured against it.

Required Methods§

Source

fn now(&self) -> Duration

Monotonic time elapsed since this clock’s origin.

Source

fn sleep( &self, duration: Duration, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'static>>

Complete once duration has passed on this clock.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§