n0_error

Trait StackResultExt

Source
pub trait StackResultExt<T, E> {
    // Required methods
    fn context(self, context: impl Display) -> Result<T, AnyError>;
    fn with_context<F, C>(self, context: F) -> Result<T, AnyError>
       where F: FnOnce(&E) -> C,
             C: Display;
}
Expand description

Provides extension methods to add context to StackErrors.

Required Methods§

Source

fn context(self, context: impl Display) -> Result<T, AnyError>

Converts the result’s error value to AnyError while providing additional context.

Source

fn with_context<F, C>(self, context: F) -> Result<T, AnyError>
where F: FnOnce(&E) -> C, C: Display,

Converts the result’s error value to AnyError while providing lazily-evaluated additional context.

The context closure is only invoked if an error occurs.

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.

Implementations on Foreign Types§

Source§

impl<T> StackResultExt<T, NoneError> for Option<T>

Source§

fn context(self, context: impl Display) -> Result<T, AnyError>

Source§

fn with_context<F, C>(self, context: F) -> Result<T, AnyError>
where F: FnOnce(&NoneError) -> C, C: Display,

Source§

impl<T, E: StackError + 'static> StackResultExt<T, E> for Result<T, E>

Source§

fn context(self, context: impl Display) -> Result<T, AnyError>

Source§

fn with_context<F, C>(self, context: F) -> Result<T, AnyError>
where F: FnOnce(&E) -> C, C: Display,

Implementors§