Skip to main content

Sleeper

Trait Sleeper 

Source
pub trait Sleeper: 'static {
    type Sleep: Future;

    // Required method
    fn sleep(&self, dur: Duration) -> Self::Sleep;
}
Expand description

A sleeper is used to generate a future that completes after a specified duration.

Required Associated Types§

Source

type Sleep: Future

The future returned by the sleep method.

Required Methods§

Source

fn sleep(&self, dur: Duration) -> Self::Sleep

Create a future that completes after a set period.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Sleeper for TokioSleeper

Available on crate feature tokio-sleep and non-WebAssembly only.
Source§

impl<F: Fn(Duration) -> Fut + 'static, Fut: Future> Sleeper for F

All Fn(Duration) -> impl Future implements Sleeper.

Source§

type Sleep = Fut