pingora_core::prelude

Trait Context

Source
pub trait Context<T> {
    // Required method
    fn err_context<C, F>(self, context: F) -> Result<T, Box<Error>>
       where C: Into<ImmutStr>,
             F: FnOnce() -> C;
}
Expand description

Helper trait to add more context to a given error

Required Methods§

Source

fn err_context<C, F>(self, context: F) -> Result<T, Box<Error>>
where C: Into<ImmutStr>, F: FnOnce() -> C,

Wrap the Err(E) in Result with more context, the existing E will be the cause.

This is a shortcut for map_err() + more_context()

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> Context<T> for Result<T, Box<Error>>

Source§

fn err_context<C, F>(self, context: F) -> Result<T, Box<Error>>
where C: Into<ImmutStr>, F: FnOnce() -> C,

Implementors§