FutureExt

Trait FutureExt 

Source
pub trait FutureExt: Future + Sized {
    // Provided methods
    fn discard(self) -> Discard<Self> { ... }
    fn boxify(self) -> BoxFuture<Self::Item, Self::Error>
       where Self: 'static + Send { ... }
    fn boxify_nonsend(self) -> BoxFutureNonSend<Self::Item, Self::Error>
       where Self: 'static { ... }
    fn left_future<B>(self) -> Either<Self, B> { ... }
    fn right_future<A>(self) -> Either<A, Self> { ... }
    fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
       where F: FnOnce(&Self::Error),
             Self: Sized { ... }
    fn inspect_result<F>(self, f: F) -> InspectResult<Self, F>
       where F: FnOnce(Result<&Self::Item, &Self::Error>),
             Self: Sized { ... }
}
Expand description

A trait implemented by default for all Futures which extends the standard functionality.

Provided Methods§

Source

fn discard(self) -> Discard<Self>

Map a Future to have Item=() and Error=(). This is useful when a future is being used to drive a computation but the actual results aren’t interesting (such as when used with Handle::spawn()).

Source

fn boxify(self) -> BoxFuture<Self::Item, Self::Error>
where Self: 'static + Send,

Create a Sendable boxed version of this Future.

Source

fn boxify_nonsend(self) -> BoxFutureNonSend<Self::Item, Self::Error>
where Self: 'static,

Create a non-Sendable boxed version of this Future.

Source

fn left_future<B>(self) -> Either<Self, B>

Shorthand for returning future::Either::A

Source

fn right_future<A>(self) -> Either<A, Self>

Shorthand for returning future::Either::B

Source

fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
where F: FnOnce(&Self::Error), Self: Sized,

Similar to future::Future::inspect, but runs the function on error

Source

fn inspect_result<F>(self, f: F) -> InspectResult<Self, F>
where F: FnOnce(Result<&Self::Item, &Self::Error>), Self: Sized,

Similar to future::Future::inspect, but runs the function on both output or error of the Future treating it as a regular Result

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.

Implementors§

Source§

impl<T> FutureExt for T
where T: Future,