EndpointResultExt

Trait EndpointResultExt 

Source
pub trait EndpointResultExt<A, B>: Endpoint<Output = Result<A, B>> + Sized {
    // Provided methods
    fn as_ok<T>(self) -> Self
       where Self::Output: IsResult<Ok = T> { ... }
    fn as_err<E>(self) -> Self
       where Self::Output: IsResult<Err = E> { ... }
    fn map_ok<F, U>(self, f: F) -> MapOk<Self, F>
       where F: FnOnce(A) -> U + Clone + Send + Sync { ... }
    fn map_err<F, U>(self, f: F) -> MapErr<Self, F>
       where F: FnOnce(B) -> U + Clone + Send + Sync { ... }
    fn err_into<U>(self) -> ErrInto<Self, U>
       where B: Into<U> { ... }
    fn and_then<F, U>(self, f: F) -> AndThen<Self, F>
       where F: FnOnce(A) -> Result<U, B> + Clone + Send + Sync { ... }
    fn or_else<F, U>(self, f: F) -> OrElse<Self, F>
       where F: FnOnce(B) -> Result<A, U> + Clone + Send + Sync { ... }
    fn unwrap_ok(self) -> UnwrapOk<Self>
       where B: Into<Error> { ... }
}
Expand description

A set of extension methods which is available when the output value is a Result.

Provided Methods§

Source

fn as_ok<T>(self) -> Self
where Self::Output: IsResult<Ok = T>,

Annotate that the successful type of associated type Output is equal to T.

Source

fn as_err<E>(self) -> Self
where Self::Output: IsResult<Err = E>,

Annotate that the error type of associated type Output is equal to E.

Source

fn map_ok<F, U>(self, f: F) -> MapOk<Self, F>
where F: FnOnce(A) -> U + Clone + Send + Sync,

Create an endpoint which will map the successful value to a new type with given function.

Source

fn map_err<F, U>(self, f: F) -> MapErr<Self, F>
where F: FnOnce(B) -> U + Clone + Send + Sync,

Create an endpoint which will map the error value to a new type with given function.

Source

fn err_into<U>(self) -> ErrInto<Self, U>
where B: Into<U>,

Create an endpoint which will convert the error value to a new type.

Source

fn and_then<F, U>(self, f: F) -> AndThen<Self, F>
where F: FnOnce(A) -> Result<U, B> + Clone + Send + Sync,

Create an endpoint which will map the successful value to a Result with given function.

Source

fn or_else<F, U>(self, f: F) -> OrElse<Self, F>
where F: FnOnce(B) -> Result<A, U> + Clone + Send + Sync,

Create an endpoint which will map the error value to a Result with given function.

Source

fn unwrap_ok(self) -> UnwrapOk<Self>
where B: Into<Error>,

Create an endpoint which will return the content of an Ok.

The term “unwrap” does not means that an unwinding will occur if the value is an Err. Instead, the error value will be converted to an Error and handled the state internally.

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<E, A, B> EndpointResultExt<A, B> for E
where E: Endpoint<Output = Result<A, B>>,