pub trait TimeoutFutureExt<T>: Future<Output = T> + Sized {
// Provided methods
fn default_timeout() -> Duration { ... }
fn with_default_timeout(self) -> Timeout<Self> ⓘ { ... }
fn with_timeout(self, timeout_value: Duration) -> Timeout<Self> ⓘ { ... }
}Expand description
Helper extension trait which allows to limit execution time for the futures. It is helpful in tests to ensure that no future will ever get stuck forever.
Provided Methods§
Sourcefn default_timeout() -> Duration
fn default_timeout() -> Duration
Returns a reasonable value that can be used as a future timeout with a certain degree of confidence that timeout won’t be triggered by the test specifics.
Sourcefn with_default_timeout(self) -> Timeout<Self> ⓘ
fn with_default_timeout(self) -> Timeout<Self> ⓘ
Adds a fixed timeout to the future.
Sourcefn with_timeout(self, timeout_value: Duration) -> Timeout<Self> ⓘ
fn with_timeout(self, timeout_value: Duration) -> Timeout<Self> ⓘ
Adds a custom timeout to the future.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".