pub trait TimerExt: Timer {
// Provided method
fn timeout<F: Future>(&self, duration: Duration, future: F) -> Timeout<F> ⓘ { ... }
}
Expand description
An extension trait on Timer
for timeouts and clock delays.
Provided Methods§
Sourcefn timeout<F: Future>(&self, duration: Duration, future: F) -> Timeout<F> ⓘ
fn timeout<F: Future>(&self, duration: Duration, future: F) -> Timeout<F> ⓘ
Wrap a Future
with a timeout.
The output of the new future will be the returned value of
future
if it completes within duration
. Otherwise, it
will be Err(TimeoutError)
.
§Limitations
This uses Timer::sleep
for its timer, and is
subject to the same limitations.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.