Skip to main content

Timer

Trait Timer 

pub trait Timer: Send + Sync {
    // Required method
    fn sleep(
        &self,
        duration: Duration,
    ) -> Pin<Box<dyn Future<Output = ()> + Send>>;
}
Expand description

The Host’s clock, which performs each Timer effect as one sleep.

The Harness polls each sleep inside the run’s own future, so a timer must not block while polled. It waits on the Host’s own runtime.

Required Methods§

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

Resolves once duration has passed.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§