Trait ErrContext

Source
pub trait ErrContext<T, E>: Sealed {
Show 15 methods // Required methods fn error_context(self, context: impl Display) -> Result<T, E>; fn warn_context(self, context: impl Display) -> Result<T, E>; fn info_context(self, context: impl Display) -> Result<T, E>; fn debug_context(self, context: impl Display) -> Result<T, E>; fn trace_context(self, context: impl Display) -> Result<T, E>; fn with_error_context<F, D>(self, f: F) -> Result<T, E> where F: FnOnce(&E) -> D, D: Display; fn with_warn_context<F, D>(self, f: F) -> Result<T, E> where F: FnOnce(&E) -> D, D: Display; fn with_info_context<F, D>(self, f: F) -> Result<T, E> where F: FnOnce(&E) -> D, D: Display; fn with_debug_context<F, D>(self, f: F) -> Result<T, E> where F: FnOnce(&E) -> D, D: Display; fn with_trace_context<F, D>(self, f: F) -> Result<T, E> where F: FnOnce(&E) -> D, D: Display; fn consume_with_error<F, D>(self, f: F) -> Option<T> where F: FnOnce(&E) -> D, D: Display; fn consume_with_warn<F, D>(self, f: F) -> Option<T> where F: FnOnce(&E) -> D, D: Display; fn consume_with_info<F, D>(self, f: F) -> Option<T> where F: FnOnce(&E) -> D, D: Display; fn consume_with_debug<F, D>(self, f: F) -> Option<T> where F: FnOnce(&E) -> D, D: Display; fn consume_with_trace<F, D>(self, f: F) -> Option<T> where F: FnOnce(&E) -> D, D: Display;
}
Expand description

For logging a Result when Err is encountered.

Required Methods§

Source

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

If Err, logging context as an “error”.

Source

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

If Err, logging context as a “warn”.

Source

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

If Err, logging context as an “info”.

Source

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

If Err, logging context as a “debug”.

Source

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

If Err, logging context as a “trace”.

Source

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

If Err, lazily logging the result of [f] as an “error”.

Source

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

If Err, lazily logging the result of [f] as a “warn”.

Source

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

If Err, lazily logging the result of [f] as an “info”.

Source

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

If Err, lazily logging the result of [f] as a “debug”.

Source

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

If Err, lazily logging the result of [f] as a “trace”.

Source

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

Consumes the Err of a Result. If Err, lazily logging the result of [f] as an “error”. Represents a bad state in which the current process cannot continue.

Source

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

Consumes the Err of a Result. If Err, lazily logging the result of [f] as a “warn”. Represents a bad state in which the current process can continue.

Source

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

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

Source

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

Consumes the Err of a Result. If Err, lazily logging the result of [f] as a “debug”.

Source

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

Consumes the Err of a Result. If Err, lazily logging the result of [f] as a “trace”.

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> ErrContext<T, E> for Result<T, E>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§