asr::future

Function timeout

Source
pub fn timeout<F: Future>(duration: Duration, future: F) -> Timeout<F> 
Available on WASI only.
Expand description

A future that resolves to None after a certain amount of time, if the provided future has not resolved yet.

§Example

let future = async {
   // do some work
};

let result = timeout(Duration::from_secs(1), future).await;
if let Some(result) = result {
   // do something with the result
} else {
  // the future timed out
}