Skip to main content

Sleep

Trait Sleep 

Source
pub trait Sleep {
    type Poll: Future;

    // Required method
    fn next_poll(&mut self) -> Self::Poll;
}
Expand description

Governs the behaviour of of polling in async functions.

There is a generic implementation for any function retuning a future. This allows e.g. to pass || tokio::time::sleep(Duration::from_millis(50)) to functions expecting sleep. That is if you use tokio as your async runtime, of course.

Required Associated Types§

Required Methods§

Source

fn next_poll(&mut self) -> Self::Poll

Between each poll next poll is executed, and the resulting future is awaited.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<S, F> Sleep for S
where S: FnMut() -> F, F: Future,

Source§

type Poll = F