Skip to main content

Context

Trait Context 

Source
pub trait Context<T, E>: Sealed {
    // Required methods
    fn context<C>(self, context: C) -> Result<T, Error>
       where C: Display + Send + Sync + 'static;
    fn with_context<C, F>(self, f: F) -> Result<T, Error>
       where C: Display + Send + Sync + 'static,
             F: FnOnce() -> C;
}
Expand description

Attach more context to an error.

Required Methods§

Source

fn context<C>(self, context: C) -> Result<T, Error>
where C: Display + Send + Sync + 'static,

Wrap the error value with additional context.

Source

fn with_context<C, F>(self, f: F) -> Result<T, Error>
where C: Display + Send + Sync + 'static, F: FnOnce() -> C,

Wrap the error value with additional context evaluated lazily.

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<T, E> Context<T, E> for Result<T, E>
where E: Error + Send + Sync + 'static,

Source§

fn context<C>(self, context: C) -> Result<T, Error>
where C: Display + Send + Sync + 'static,

Source§

fn with_context<C, F>(self, context: F) -> Result<T, Error>
where C: Display + Send + Sync + 'static, F: FnOnce() -> C,

Source§

impl<T> Context<T, !> for Option<T>

Source§

fn context<C>(self, context: C) -> Result<T, Error>
where C: Display + Send + Sync + 'static,

Source§

fn with_context<C, F>(self, context: F) -> Result<T, Error>
where C: Display + Send + Sync + 'static, F: FnOnce() -> C,

Implementors§