diffusion_rs_common::core::error

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.

Inspired by anyhow::Context.

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 that is evaluated lazily only once an error does occur.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

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

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,

Implementors§