Function timeout

Source
pub async fn timeout<F, T>(dur: Duration, f: F) -> Result<T, TimeoutError>
where F: Future<Output = T>,
Expand description

Execute a future or error on timeout, whichever comes first.

ยงErrors

Will return Err if the timeout occurs before the future is ready.