Skip to main content

AsyncResultChainExt

Trait AsyncResultChainExt 

Source
pub trait AsyncResultChainExt<T, E>: Future<Output = Result<T, E>> + Sized {
    // Provided method
    fn and_then_async<Fut, F, U>(self, f: F) -> AndThenAsync<Self, Fut, F> 
       where F: FnOnce(T) -> Fut,
             Fut: Future<Output = Result<U, E>> { ... }
}
Expand description

Extension trait adding .and_then_async() for chaining futures returning results.

This allows chaining asynchronous computations that depend on the success of the previous one.

Provided Methods§

Source

fn and_then_async<Fut, F, U>(self, f: F) -> AndThenAsync<Self, Fut, F>
where F: FnOnce(T) -> Fut, Fut: Future<Output = Result<U, E>>,

Chains an asynchronous computation to execute if the previous future resolves to Ok.

The closure f takes the successful value and returns a new future producing a Result.

§Parameters
  • f: the chaining closure producing the next future.
§Returns

A future that resolves to the chained computation’s 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, E, F> AsyncResultChainExt<T, E> for F
where F: Future<Output = Result<T, E>> + Sized,