pub async fn timeout<F: Future>(
duration: Duration,
future: F,
) -> Result<F::Output, Elapsed>
Available on crate feature
time
only.Expand description
Require a Future
to complete before the specified duration has elapsed.
If the future completes before the duration has elapsed, then the completed value is returned. Otherwise, an error is returned and the future is canceled.