Skip to main content

Sleep

Trait Sleep 

Source
pub trait Sleep: MaybeSend + MaybeSync {
    // Required method
    fn sleep(&self, duration: Duration) -> BoxFuture<'static, ()>;
}
Expand description

Injected timer, the counterpart of Clock for deadlines: Instant and tokio::time are not available on every target, so an adapter passes in its runtime’s sleep (tokio::time::sleep on native, worker::Delay on Workers) and core code bounds an external call with with_timeout.

Required Methods§

Source

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

A future that completes once duration has elapsed.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T: Sleep + ?Sized> Sleep for Arc<T>

Source§

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

Implementors§