Skip to main content

Context

Trait Context 

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

anyhow::Context-like trait for adding contexts and getting Errors.

Required Methods§

Source

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

Source

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

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> Context<T, Infallible> for Option<T>

Source§

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

Source§

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

Source§

impl<T, E> Context<T, E> for Result<T, E>
where E: Into<Error>,

Source§

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

Source§

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

Implementors§