Trait ProblemResultExt

Source
pub trait ProblemResultExt: ResultExt {
    // Required methods
    fn catch_err<E>(self) -> Result<Result<Self::Value, E>>
       where E: Error + Send + Sync + 'static;
    fn optional(self) -> Result<Option<Self::Value>>;
}
Expand description

Extension methods on Result<T, Problem>.

Required Methods§

Source

fn catch_err<E>(self) -> Result<Result<Self::Value, E>>
where E: Error + Send + Sync + 'static,

Catch a specific error type E.

Returns Ok(Ok(_)) when the source Result<T> is a T, returns Ok(Err(_)) when its is a Problem that can downcast to an E, and returns Err(_) otherwise.

Useful when there is a need to handle a specific error differently, e.g. a NotFound error.

§Errors

Returns Err if self contains a Problem which is not an E.

Source

fn optional(self) -> Result<Option<Self::Value>>

Catch a NotFound and convert it to None.

§Errors

Returns Err if self contains a Problem which is not a NotFound.

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§