Trait FutureExt

Source
pub trait FutureExt<T>: Sized {
    // Required methods
    fn map<U>(self, f: impl FnOnce(T) -> U + Send + 'static) -> AsyncTask<U> 
       where U: Send + 'static + NotResult;
    fn on_ok<U>(self, f: impl FnOnce(T) -> U + Send + 'static) -> AsyncTask<U> 
       where U: Send + 'static + NotResult;
    fn on_error<U>(
        self,
        f: impl FnOnce(RecvError) -> U + Send + 'static,
    ) -> AsyncTask<U> 
       where U: Send + 'static + NotResult,
             T: Into<U>;
    fn on_result<U>(
        self,
        f: impl FnOnce(Result<T, RecvError>) -> U + Send + 'static,
    ) -> AsyncTask<U> 
       where U: Send + 'static + NotResult;
    fn map_ok<U>(self, f: impl FnOnce(T) -> U + Send + 'static) -> AsyncTask<U> 
       where U: Send + 'static + NotResult;
    fn tap_ok(self, f: impl FnOnce(&T) + Send + 'static) -> AsyncTask<T> 
       where T: NotResult;
    fn tap_err(
        self,
        f: impl FnOnce(&RecvError) + Send + 'static,
    ) -> AsyncTask<T> 
       where T: NotResult;
}
Expand description

Extension trait for futures that provides additional combinators for async operations.

Required Methods§

Source

fn map<U>(self, f: impl FnOnce(T) -> U + Send + 'static) -> AsyncTask<U>
where U: Send + 'static + NotResult,

Maps the success value of the future to a new type using the provided function.

Source

fn on_ok<U>(self, f: impl FnOnce(T) -> U + Send + 'static) -> AsyncTask<U>
where U: Send + 'static + NotResult,

Executes a function when the future completes successfully.

Source

fn on_error<U>( self, f: impl FnOnce(RecvError) -> U + Send + 'static, ) -> AsyncTask<U>
where U: Send + 'static + NotResult, T: Into<U>,

Executes a function when the future encounters an error.

Source

fn on_result<U>( self, f: impl FnOnce(Result<T, RecvError>) -> U + Send + 'static, ) -> AsyncTask<U>
where U: Send + 'static + NotResult,

Handles both success and error cases with a result handler.

Source

fn map_ok<U>(self, f: impl FnOnce(T) -> U + Send + 'static) -> AsyncTask<U>
where U: Send + 'static + NotResult,

Maps the success value while preserving error state.

Source

fn tap_ok(self, f: impl FnOnce(&T) + Send + 'static) -> AsyncTask<T>
where T: NotResult,

Applies a function to the success value without consuming it.

Source

fn tap_err(self, f: impl FnOnce(&RecvError) + Send + 'static) -> AsyncTask<T>
where T: NotResult,

Applies a function to the error value without consuming it.

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: Send + 'static + NotResult> FutureExt<T> for AsyncTask<T>