pub async fn with_timeout<S, F>( sleep: &S, after: Duration, fut: F, ) -> Result<F::Output, Elapsed>where S: Sleep + ?Sized, F: Future,
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.
fut
Elapsed
sleep
after
Elapsed when the timer completes first.