Skip to main content

ResultExt

Trait ResultExt 

Source
pub trait ResultExt {
    // Required methods
    fn log_err(self, msg: impl Display) -> Self;
    fn log_err_with<F>(self, f: F) -> Self
       where F: FnOnce() -> String;
    fn log_warn(self, msg: impl Display) -> Self;
    fn log_warn_with<F>(self, f: F) -> Self
       where F: FnOnce() -> String;
    fn log_info(self, msg: impl Display) -> Self;
    fn log_info_with<F>(self, f: F) -> Self
       where F: FnOnce() -> String;
    fn log_debug(self, msg: impl Display) -> Self;
    fn log_debug_with<F>(self, f: F) -> Self
       where F: FnOnce() -> String;
    fn log_trace(self, msg: impl Display) -> Self;
    fn log_trace_with<F>(self, f: F) -> Self
       where F: FnOnce() -> String;
}
Expand description

Extension trait for Result to log errors and warnings using the tracing crate.

Required Methods§

Source

fn log_err(self, msg: impl Display) -> Self

Log errors at error level with a static message.

If you don’t care about the error message, call eg. log_err("").

Source

fn log_err_with<F>(self, f: F) -> Self
where F: FnOnce() -> String,

Log errors at error level with a message generated by a closure.

Source

fn log_warn(self, msg: impl Display) -> Self

Log errors at warning level with a static message.

If you don’t care about the error message, call eg. log_warn("").

Source

fn log_warn_with<F>(self, f: F) -> Self
where F: FnOnce() -> String,

Log errors at warning level with a message generated by a closure.

Source

fn log_info(self, msg: impl Display) -> Self

Log errors at informational level with a static message.

If you don’t care about the error message, call eg. log_warn("").

Source

fn log_info_with<F>(self, f: F) -> Self
where F: FnOnce() -> String,

Log errors at informational level with a message generated by a closure.

Source

fn log_debug(self, msg: impl Display) -> Self

Log errors at debug level with a static message.

If you don’t care about the error message, call eg. log_warn("").

Source

fn log_debug_with<F>(self, f: F) -> Self
where F: FnOnce() -> String,

Log errors at debug level with a message generated by a closure.

Source

fn log_trace(self, msg: impl Display) -> Self

Log errors at trace level with a static message.

If you don’t care about the error message, call eg. log_warn("").

Source

fn log_trace_with<F>(self, f: F) -> Self
where F: FnOnce() -> String,

Log errors at trace level with a message generated by a closure.

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> ResultExt for Result<T, E>
where E: Debug,

Available on crate feature tracing only.
Source§

fn log_err(self, msg: impl Display) -> Self

Source§

fn log_err_with<F>(self, msg: F) -> Self
where F: FnOnce() -> String,

Source§

fn log_warn(self, msg: impl Display) -> Self

Source§

fn log_warn_with<F>(self, msg: F) -> Self
where F: FnOnce() -> String,

Source§

fn log_info(self, msg: impl Display) -> Self

Source§

fn log_info_with<F>(self, msg: F) -> Self
where F: FnOnce() -> String,

Source§

fn log_debug(self, msg: impl Display) -> Self

Source§

fn log_debug_with<F>(self, msg: F) -> Self
where F: FnOnce() -> String,

Source§

fn log_trace(self, msg: impl Display) -> Self

Source§

fn log_trace_with<F>(self, msg: F) -> Self
where F: FnOnce() -> String,

Implementors§