Function with_timeout
pub async fn with_timeout<F>(
timeout: Duration,
fut: F,
) -> Result<<F as Future>::Output, TimeoutError>where
F: Future,Available on crate feature
time only.Expand description
Runs a given future with a timeout.
If the future completes before the timeout, its output is returned. Otherwise, on timeout,
work on the future is stopped (poll is no longer called), the future is dropped and Err(TimeoutError) is returned.