pub trait Context: Sealed {
// Required methods
fn module<D>(self, name: D) -> Self
where D: Display + Send + Sync + 'static,
Self: Sized;
fn with_module<D>(self, f: impl FnOnce() -> D) -> Self
where D: Display + Send + Sync + 'static;
fn value<D>(self, name: D) -> Self
where D: Display + Send + Sync + 'static,
Self: Sized;
fn with_value<D>(self, f: impl FnOnce() -> D) -> Self
where D: Display + Send + Sync + 'static,
Self: Sized;
}
Expand description
Required Methods§
Sourcefn module<D>(self, name: D) -> Self
fn module<D>(self, name: D) -> Self
Add the name of this module to the context of the error.
This method adds context to the Error
so that it knows in which
module the error occurred. It is perfectly fine to never use it, as long
as you don’t mind cryptic errors.
Modules should be added in the following order, from the module where the error occured and then its parent module up until the root module.
Sourcefn with_module<D>(self, f: impl FnOnce() -> D) -> Self
fn with_module<D>(self, f: impl FnOnce() -> D) -> Self
The same as Context::module
but lazily-evaluated.
Sourcefn value<D>(self, name: D) -> Self
fn value<D>(self, name: D) -> Self
Add the name of the value to the context of the error.
This method adds context to the Error
so that it knows in which
value the error occurred. It is perfectly fine to never use it, as long
as you don’t mind cryptic errors.
Sourcefn with_value<D>(self, f: impl FnOnce() -> D) -> Self
fn with_value<D>(self, f: impl FnOnce() -> D) -> Self
The same as Context::value
but lazily-evaluated.
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.