pub trait Context<T> {
// Required methods
fn context(self, context: impl Into<String>) -> Result<T, CaptureError>;
fn with_context<S: Into<String>>(
self,
f: impl FnOnce() -> S,
) -> Result<T, CaptureError>;
}Expand description
Attach context to a fallible value, mapping its error into CaptureError::Backend
while preserving the original cause. Mirrors anyhow::Context, so a call site only has
to import crate::error::Context instead of anyhow::Context.
Required Methods§
Sourcefn context(self, context: impl Into<String>) -> Result<T, CaptureError>
fn context(self, context: impl Into<String>) -> Result<T, CaptureError>
Wrap the error with a fixed context message.
Sourcefn with_context<S: Into<String>>(
self,
f: impl FnOnce() -> S,
) -> Result<T, CaptureError>
fn with_context<S: Into<String>>( self, f: impl FnOnce() -> S, ) -> Result<T, CaptureError>
Wrap the error with a lazily-built context message (only computed on error).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".