Trait ErrorContext
pub trait ErrorContext: SealedErrorContext {
type Context;
type OpaqueContext;
Show 16 methods
// Required methods
fn into_box_error(self) -> Self::Context;
fn into_opaque_error(self) -> Self::OpaqueContext;
fn context<M>(self, value: M) -> Self::Context
where M: Debug + Display + Send + Sync + 'static;
fn context_hex<M>(self, value: M) -> Self::Context
where M: Debug + Send + Sync + 'static;
fn context_debug<M>(self, value: M) -> Self::Context
where M: Debug + Send + Sync + 'static;
fn context_field<M>(self, key: &'static str, value: M) -> Self::Context
where M: Debug + Display + Send + Sync + 'static;
fn context_str_field<M>(self, key: &'static str, value: M) -> Self::Context
where M: Into<String>;
fn context_hex_field<M>(self, key: &'static str, value: M) -> Self::Context
where M: Debug + Send + Sync + 'static;
fn context_debug_field<M>(
self,
key: &'static str,
value: M,
) -> Self::Context
where M: Debug + Send + Sync + 'static;
fn with_context<C, F>(self, cb: F) -> Self::Context
where C: Debug + Display + Send + Sync + 'static,
F: FnOnce() -> C;
fn with_context_hex<C, F>(self, cb: F) -> Self::Context
where C: Debug + Send + Sync + 'static,
F: FnOnce() -> C;
fn with_context_debug<C, F>(self, cb: F) -> Self::Context
where C: Debug + Send + Sync + 'static,
F: FnOnce() -> C;
fn with_context_field<C, F>(self, key: &'static str, cb: F) -> Self::Context
where C: Debug + Display + Send + Sync + 'static,
F: FnOnce() -> C;
fn with_context_str_field<C, F>(
self,
key: &'static str,
cb: F,
) -> Self::Context
where C: Into<String>,
F: FnOnce() -> C;
fn with_context_hex_field<C, F>(
self,
key: &'static str,
cb: F,
) -> Self::Context
where C: Debug + Send + Sync + 'static,
F: FnOnce() -> C;
fn with_context_debug_field<C, F>(
self,
key: &'static str,
cb: F,
) -> Self::Context
where C: Debug + Send + Sync + 'static,
F: FnOnce() -> C;
}Expand description
Extends the Result and Option types with methods for adding context to errors.
See the module level documentation for more information.
Required Associated Types§
type Context
type Context
The resulting contexct type after adding context to the contained error.
type OpaqueContext
type OpaqueContext
The resulting contexct type after turning the error into an opaque error
Required Methods§
fn into_box_error(self) -> Self::Context
fn into_box_error(self) -> Self::Context
Return a err variant for Self::Context as BoxError.
fn into_opaque_error(self) -> Self::OpaqueContext
fn into_opaque_error(self) -> Self::OpaqueContext
Return a err variant for Self::OpaqueContext as OpaqueError.
fn context_hex<M>(self, value: M) -> Self::Context
fn context_hex<M>(self, value: M) -> Self::Context
Add context to the contained error,
using fmt::LowerHex as fmt::Debug and [fmt::Display].
fn context_debug<M>(self, value: M) -> Self::Context
fn context_debug<M>(self, value: M) -> Self::Context
Add context to the contained error,
using fmt::Debug as [fmt::Display].
fn context_field<M>(self, key: &'static str, value: M) -> Self::Context
fn context_field<M>(self, key: &'static str, value: M) -> Self::Context
Add keyed context to the contained error.
fn context_str_field<M>(self, key: &'static str, value: M) -> Self::Context
fn context_str_field<M>(self, key: &'static str, value: M) -> Self::Context
Same as Self::context_field but using a string-like value,
this is useful in case you need to pass a string slice which is borrowed
and thus cannot be passed as part of ’static error.
fn context_hex_field<M>(self, key: &'static str, value: M) -> Self::Context
fn context_hex_field<M>(self, key: &'static str, value: M) -> Self::Context
Add keyed context to the contained error
using fmt::LowerHex as fmt::Debug and [fmt::Display].
fn context_debug_field<M>(self, key: &'static str, value: M) -> Self::Context
fn context_debug_field<M>(self, key: &'static str, value: M) -> Self::Context
Add keyed context to the contained error
using fmt::Debug as [fmt::Display].
fn with_context<C, F>(self, cb: F) -> Self::Context
fn with_context<C, F>(self, cb: F) -> Self::Context
Lazily add a context to the contained error, if it exists.
fn with_context_hex<C, F>(self, cb: F) -> Self::Context
fn with_context_hex<C, F>(self, cb: F) -> Self::Context
Lazily add a context to the contained error, if it exists.
using fmt::LowerHex as fmt::Debug and [fmt::Display].
fn with_context_debug<C, F>(self, cb: F) -> Self::Context
fn with_context_debug<C, F>(self, cb: F) -> Self::Context
Lazily add a context to the contained error, if it exists.
using fmt::Debug as [fmt::Display].
fn with_context_field<C, F>(self, key: &'static str, cb: F) -> Self::Context
fn with_context_field<C, F>(self, key: &'static str, cb: F) -> Self::Context
Lazily add keyed context to the contained error, if it exists.
fn with_context_str_field<C, F>(self, key: &'static str, cb: F) -> Self::Context
fn with_context_str_field<C, F>(self, key: &'static str, cb: F) -> Self::Context
Same as Self::with_context_field but using a string-like value,
this is useful in case you need to pass a string slice which is borrowed
and thus cannot be passed as part of ’static error.
fn with_context_hex_field<C, F>(self, key: &'static str, cb: F) -> Self::Context
fn with_context_hex_field<C, F>(self, key: &'static str, cb: F) -> Self::Context
Lazily add keyed context to the contained error, if it exists
using fmt::LowerHex as fmt::Debug and [fmt::Display].
fn with_context_debug_field<C, F>(
self,
key: &'static str,
cb: F,
) -> Self::Context
fn with_context_debug_field<C, F>( self, key: &'static str, cb: F, ) -> Self::Context
Lazily add keyed context to the contained error, if it exists
using fmt::Debug as [fmt::Display].
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.