error_set

Trait ResultContext

Source
pub trait ResultContext<T, E>: Sealed {
Show 15 methods // Required methods fn error(self, context: impl Display) -> Result<T, E>; fn warn(self, context: impl Display) -> Result<T, E>; fn info(self, context: impl Display) -> Result<T, E>; fn debug(self, context: impl Display) -> Result<T, E>; fn trace(self, context: impl Display) -> Result<T, E>; fn with_error<F: FnOnce(&E) -> D, D: Display>(self, f: F) -> Result<T, E>; fn with_warn<F: FnOnce(&E) -> D, D: Display>(self, f: F) -> Result<T, E>; fn with_info<F: FnOnce(&E) -> D, D: Display>(self, f: F) -> Result<T, E>; fn with_debug<F: FnOnce(&E) -> D, D: Display>(self, f: F) -> Result<T, E>; fn with_trace<F: FnOnce(&E) -> D, D: Display>(self, f: F) -> Result<T, E>; fn consume_with_error<F: FnOnce(E) -> D, D: Display>( self, f: F, ) -> Option<T>; fn consume_with_warn<F: FnOnce(E) -> D, D: Display>(self, f: F) -> Option<T>; fn consume_with_info<F: FnOnce(E) -> D, D: Display>(self, f: F) -> Option<T>; fn consume_with_debug<F: FnOnce(E) -> D, D: Display>( self, f: F, ) -> Option<T>; fn consume_with_trace<F: FnOnce(E) -> D, D: Display>( self, f: F, ) -> Option<T>;
}
Available on crate features tracing or log or defmt or context_stub only.
Expand description

For logging a Result when an Err is encountered.

Required Methods§

Source

fn error(self, context: impl Display) -> Result<T, E>

Log the context as an “error” if the Result is an Err.

Source

fn warn(self, context: impl Display) -> Result<T, E>

Log the context as an “warn” if the Result is an Err.

Source

fn info(self, context: impl Display) -> Result<T, E>

Log the context as an “info” if the Result is an Err.

Source

fn debug(self, context: impl Display) -> Result<T, E>

Log the context as an “debug” if the Result is an Err.

Source

fn trace(self, context: impl Display) -> Result<T, E>

Log the context as an “trace” if the Result is an Err.

Source

fn with_error<F: FnOnce(&E) -> D, D: Display>(self, f: F) -> Result<T, E>

Lazily call [f] if the Result is an Err and log as an “error”.

Source

fn with_warn<F: FnOnce(&E) -> D, D: Display>(self, f: F) -> Result<T, E>

Lazily call [f] if the Result is an Err and log as an “warn”.

Source

fn with_info<F: FnOnce(&E) -> D, D: Display>(self, f: F) -> Result<T, E>

Lazily call [f] if the Result is an Err and log as an “info”.

Source

fn with_debug<F: FnOnce(&E) -> D, D: Display>(self, f: F) -> Result<T, E>

Lazily call [f] if the Result is an Err and log as an “debug”.

Source

fn with_trace<F: FnOnce(&E) -> D, D: Display>(self, f: F) -> Result<T, E>

Lazily call [f] if the Result is an Err and log as an “trace”.

Source

fn consume_with_error<F: FnOnce(E) -> D, D: Display>(self, f: F) -> Option<T>

Consumes the Err of a Result. if Err, logging as an “error” with the result of [f].

Source

fn consume_with_warn<F: FnOnce(E) -> D, D: Display>(self, f: F) -> Option<T>

Consumes the Err of a Result. if Err, logging as an “warn” with the result of [f].

Source

fn consume_with_info<F: FnOnce(E) -> D, D: Display>(self, f: F) -> Option<T>

Consumes the Err of a Result. if Err, logging as an “info” with the result of [f].

Source

fn consume_with_debug<F: FnOnce(E) -> D, D: Display>(self, f: F) -> Option<T>

Consumes the Err of a Result. if Err, logging as an “debug” with the result of [f].

Source

fn consume_with_trace<F: FnOnce(E) -> D, D: Display>(self, f: F) -> Option<T>

Consumes the Err of a Result. if Err, logging as an “trace” with the result of [f].

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.

Implementations on Foreign Types§

Source§

impl<T, E> ResultContext<T, E> for Result<T, E>

Source§

fn error(self, context: impl Display) -> Result<T, E>

Available on crate features tracing or log or defmt or context_stub only.
Source§

fn warn(self, context: impl Display) -> Result<T, E>

Available on crate features tracing or log or defmt or context_stub only.
Source§

fn info(self, context: impl Display) -> Result<T, E>

Available on crate features tracing or log or defmt or context_stub only.
Source§

fn debug(self, context: impl Display) -> Result<T, E>

Available on crate features tracing or log or defmt or context_stub only.
Source§

fn trace(self, context: impl Display) -> Result<T, E>

Available on crate features tracing or log or defmt or context_stub only.
Source§

fn with_error<F: FnOnce(&E) -> D, D: Display>(self, f: F) -> Result<T, E>

Available on crate features tracing or log or defmt or context_stub only.
Source§

fn with_warn<F: FnOnce(&E) -> D, D: Display>(self, f: F) -> Result<T, E>

Available on crate features tracing or log or defmt or context_stub only.
Source§

fn with_info<F: FnOnce(&E) -> D, D: Display>(self, f: F) -> Result<T, E>

Available on crate features tracing or log or defmt or context_stub only.
Source§

fn with_debug<F: FnOnce(&E) -> D, D: Display>(self, f: F) -> Result<T, E>

Available on crate features tracing or log or defmt or context_stub only.
Source§

fn with_trace<F: FnOnce(&E) -> D, D: Display>(self, f: F) -> Result<T, E>

Available on crate features tracing or log or defmt or context_stub only.
Source§

fn consume_with_error<F: FnOnce(E) -> D, D: Display>(self, f: F) -> Option<T>

Available on crate features tracing or log or defmt or context_stub only.
Source§

fn consume_with_warn<F: FnOnce(E) -> D, D: Display>(self, f: F) -> Option<T>

Available on crate features tracing or log or defmt or context_stub only.
Source§

fn consume_with_info<F: FnOnce(E) -> D, D: Display>(self, f: F) -> Option<T>

Available on crate features tracing or log or defmt or context_stub only.
Source§

fn consume_with_debug<F: FnOnce(E) -> D, D: Display>(self, f: F) -> Option<T>

Available on crate features tracing or log or defmt or context_stub only.
Source§

fn consume_with_trace<F: FnOnce(E) -> D, D: Display>(self, f: F) -> Option<T>

Available on crate features tracing or log or defmt or context_stub only.

Implementors§