Trait future_utils::FutureExt
[−]
[src]
pub trait FutureExt: Future + Sized { fn into_boxed(self) -> BoxFuture<Self::Item, Self::Error>
where
Self: 'static, { ... } fn until<C>(self, condition: C) -> Until<Self, C>
where
C: Future<Item = ()>,
Self::Error: From<C::Error>, { ... } fn infallible<E>(self) -> Infallible<Self, E>
where
Self: Future<Error = Void>, { ... } fn log_error(
self,
level: LogLevel,
description: &'static str
) -> LogError<Self>
where
Self: Future<Item = ()>,
Self::Error: Display, { ... } }
Extension trait for Future
.
Provided Methods
fn into_boxed(self) -> BoxFuture<Self::Item, Self::Error> where
Self: 'static,
Self: 'static,
Wraps a future into a boxed future, making type-checking easier at the expense of an extra layer of indirection at runtime.
fn until<C>(self, condition: C) -> Until<Self, C> where
C: Future<Item = ()>,
Self::Error: From<C::Error>,
C: Future<Item = ()>,
Self::Error: From<C::Error>,
Run this future until some condition is met. If condition
resolves before self
then
None
is returned.
Example
let my_future_with_timeout = my_future.until(Timeout::new(Duration::from_secs(1)));
fn infallible<E>(self) -> Infallible<Self, E> where
Self: Future<Error = Void>,
Self: Future<Error = Void>,
For futures which can't fail (ie. which have error type Void
), cast the error type to
some inferred type.
fn log_error(self, level: LogLevel, description: &'static str) -> LogError<Self> where
Self: Future<Item = ()>,
Self::Error: Display,
Self: Future<Item = ()>,
Self::Error: Display,
Take a future which returns ()
and log its error if it fails. The returned future cannot
fail and will always resolve to ()
.