Skip to main content

AsyncClock

Trait AsyncClock 

Source
pub trait AsyncClock: Clock {
    // Required method
    fn sleep(&self, duration: Duration) -> impl Future<Output = ()> + Send;
}
Expand description

Extension trait adding async sleep to Clock.

This is separate from the base Clock trait because async methods cannot be in traits without additional machinery, and we want to keep telltale-types dependency-free.

Required Methods§

Source

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

Sleep for a duration asynchronously.

In simulation mode this may advance simulated time immediately.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl AsyncClock for MockClock

Implement AsyncClock for MockClock.

Sleep immediately advances simulated time without blocking.

Source§

impl AsyncClock for SystemClock