Trait finchers_ext::result::EndpointResultExt
[−]
[src]
pub trait EndpointResultExt<A, B>: Endpoint<Output = Result<A, B>> + Sized { 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>, { ... } }
A set of extension methods which is available when the output value is a Result
.
Provided Methods
fn as_ok<T>(self) -> Self where
Self::Output: IsResult<Ok = T>,
Self::Output: IsResult<Ok = T>,
Annotate that the successful type of associated type Output
is equal to T
.
fn as_err<E>(self) -> Self where
Self::Output: IsResult<Err = E>,
Self::Output: IsResult<Err = E>,
Annotate that the error type of associated type Output
is equal to E
.
fn map_ok<F, U>(self, f: F) -> MapOk<Self, F> where
F: FnOnce(A) -> U + Clone + Send + Sync,
F: FnOnce(A) -> U + Clone + Send + Sync,
Create an endpoint which will map the successful value to a new type with given function.
fn map_err<F, U>(self, f: F) -> MapErr<Self, F> where
F: FnOnce(B) -> U + Clone + Send + Sync,
F: FnOnce(B) -> U + Clone + Send + Sync,
Create an endpoint which will map the error value to a new type with given function.
fn err_into<U>(self) -> ErrInto<Self, U> where
B: Into<U>,
B: Into<U>,
Create an endpoint which will convert the error value to a new type.
fn and_then<F, U>(self, f: F) -> AndThen<Self, F> where
F: FnOnce(A) -> Result<U, B> + Clone + Send + Sync,
F: FnOnce(A) -> Result<U, B> + Clone + Send + Sync,
Create an endpoint which will map the successful value to a Result
with given function.
fn or_else<F, U>(self, f: F) -> OrElse<Self, F> where
F: FnOnce(B) -> Result<A, U> + Clone + Send + Sync,
F: FnOnce(B) -> Result<A, U> + Clone + Send + Sync,
Create an endpoint which will map the error value to a Result
with given function.
fn unwrap_ok(self) -> UnwrapOk<Self> where
B: Into<Error>,
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.