pub trait Context<T> {
// Required methods
fn context<C>(self, context: C) -> Result<T>
where C: Display + Debug + Send + Sync + 'static;
fn with_context<C, F>(self, f: F) -> Result<T>
where C: Display + Debug + Send + Sync + 'static,
F: FnOnce() -> C;
fn with_field<V>(self, key: &'static str, value: V) -> Result<T>
where V: Display;
fn with_field_debug<V>(self, key: &'static str, value: V) -> Result<T>
where V: Debug;
}
Expand description
Extension trait for adding context and fields to errors.
Required Methods§
Sourcefn with_context<C, F>(self, f: F) -> Result<T>
fn with_context<C, F>(self, f: F) -> Result<T>
Wrap the error value with additional context that is evaluated lazily.
Sourcefn with_field<V>(self, key: &'static str, value: V) -> Result<T>where
V: Display,
fn with_field<V>(self, key: &'static str, value: V) -> Result<T>where
V: Display,
Add a named field to the error.
Sourcefn with_field_debug<V>(self, key: &'static str, value: V) -> Result<T>where
V: Debug,
fn with_field_debug<V>(self, key: &'static str, value: V) -> Result<T>where
V: Debug,
Add a named field with debug formatting to the error.
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.