Skip to main content

sleep

Function sleep 

Source
pub async fn sleep(duration: Duration)
Expand description

Completes after duration on every target: a Tokio timer natively and a setTimeout in browsers.

Await it inside work started through the application’s spawner (for example RuntimeSpawner::spawn_into); natively it needs the Tokio runtime those tasks run on.