Skip to main content

Context

Trait Context 

Source
pub trait Context<O, E: Into<Box<dyn StdError + Send + Sync + 'static>>> {
    // Required methods
    fn context<T: 'static + Display + Debug>(
        self,
        kind: T,
    ) -> Result<O, Error<T>>;
    fn annotate(self) -> Result<O, Error<AnnotatedError>>;
    fn map_context<T: 'static + Display + Debug, F: FnOnce(&E) -> T>(
        self,
        op: F,
    ) -> Result<O, Error<T>>;
}
Expand description

Convenience methods for Result<> to turn the error into a decorated Error

Required Methods§

Source

fn context<T: 'static + Display + Debug>(self, kind: T) -> Result<O, Error<T>>

Decorate the error with a kind of type T and the source Location

Source

fn annotate(self) -> Result<O, Error<AnnotatedError>>

Decorate the error just with the source Location

Source

fn map_context<T: 'static + Display + Debug, F: FnOnce(&E) -> T>( self, op: F, ) -> Result<O, Error<T>>

Decorate the error with a kind of type T produced with a FnOnce(&error) and the source Location

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<O, E: Into<Box<dyn StdError + Send + Sync + 'static>>> Context<O, E> for Result<O, E>

Source§

fn context<T: 'static + Display + Debug>(self, kind: T) -> Result<O, Error<T>>

Source§

fn annotate(self) -> Result<O, Error<AnnotatedError>>

Source§

fn map_context<T: 'static + Display + Debug, F: FnOnce(&E) -> T>( self, op: F, ) -> Result<O, Error<T>>

Implementors§