pub trait Context: Sealed {
// Required methods
fn module<D>(self, name: D) -> Self
where D: Display,
Self: Sized;
fn with_module<D>(self, f: impl FnOnce() -> D) -> Self
where D: Display;
fn trace(self, trace: Trace) -> Self;
fn with_trace(self, f: impl FnOnce() -> Trace) -> Self;
fn value<D>(self, name: D) -> Self
where D: Display,
Self: Sized;
fn with_value<D>(self, f: impl FnOnce() -> D) -> Self
where D: Display,
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) -> Selfwhere
D: Display,
fn with_module<D>(self, f: impl FnOnce() -> D) -> Selfwhere
D: Display,
The same as Context::module but lazily-evaluated.
Sourcefn trace(self, trace: Trace) -> Self
fn trace(self, trace: Trace) -> Self
Set the trace of the error.
This method overwrites the module trace completely with trace.
Sourcefn with_trace(self, f: impl FnOnce() -> Trace) -> Self
fn with_trace(self, f: impl FnOnce() -> Trace) -> Self
Set the trace of the error.
The same as Context::trace 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.