Skip to main content

with_timeout

Function with_timeout 

Source
pub async fn with_timeout<S, F>(
    sleep: &S,
    after: Duration,
    fut: F,
) -> Result<F::Output, Elapsed>
where S: Sleep + ?Sized, F: Future,
Expand description

Run fut, giving up with Elapsed once sleep says after has passed. A future that is ready wins over an elapsed timer, and a timed-out future is dropped, so the caller must not assume its side effects did not land.

ยงErrors

Elapsed when the timer completes first.