Skip to main content

timeout

Function timeout 

Source
pub async fn timeout<F: Future>(
    runtime: &dyn Runtime,
    duration: Duration,
    future: F,
) -> Option<F::Output>
Expand description

Await future for at most duration on runtime’s clock: its output, or None when duration passed first.

The duration counts from the first poll, not from the call. future is polled before the timer, so a ready future wins even at Duration::ZERO. Any duration, Duration::MAX included, is valid.