Skip to main content

Sleeper

Trait Sleeper 

Source
pub trait Sleeper:
    Send
    + Sync
    + 'static {
    // Required method
    fn sleep(&self, dur: Duration) -> BoxFuture<'static, ()>;
}
Expand description

The timer the wake seam sleeps on, injected so this crate needs no runtime.

One method, deliberately: a wake needs to know that an interval passed, not what time it is. Anything richer (deadlines, cancellation tokens, an interval stream) would be an executor’s API smuggled back in through the trait.

Required Methods§

Source

fn sleep(&self, dur: Duration) -> BoxFuture<'static, ()>

A future that completes no sooner than dur from now. Being late is allowed and expected; being early is not.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§