pub trait FutureExt {
// Required methods
fn with_timeout(self, duration: Duration) -> Timeout<Self>
where Self: Sized;
fn with_timeout_at(self, deadline: Instant) -> Timeout<Self>
where Self: Sized;
}Expand description
The FutureExt trait is a trait that provides a more ergonomic way to
extend futures with additional functionality. Similar to the IteratorExt
trait from the itertools crate, but for futures.
Required Methods§
Sourcefn with_timeout(self, duration: Duration) -> Timeout<Self>where
Self: Sized,
fn with_timeout(self, duration: Duration) -> Timeout<Self>where
Self: Sized,
Attach a timeout to the future.
This is a convenience method that wraps the [tokio::time::timeout]
function. The future will automatically cancel after the timeout has
elapsed. This is equivalent to calling
with_timeout_at(tokio::time::Instant::now() + duration).
Sourcefn with_timeout_at(self, deadline: Instant) -> Timeout<Self>where
Self: Sized,
fn with_timeout_at(self, deadline: Instant) -> Timeout<Self>where
Self: Sized,
Attach a timeout to the future.
This is a convenience method that wraps the [tokio::time::timeout_at]
function. The future will automatically cancel after the timeout has
elapsed. Unlike the with_timeout method, this method allows you to
specify a deadline instead of a duration.