Skip to main content

TimeoutFutureExt

Trait TimeoutFutureExt 

Source
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§

Source

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.

Source

fn with_default_timeout(self) -> Timeout<Self> ⓘ

Adds a fixed timeout to the future.

Source

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".

Implementors§

Source§

impl<T, U> TimeoutFutureExt<T> for U
where U: Future<Output = T> + Sized,