Skip to main content

ResultExt

Trait ResultExt 

Source
pub trait ResultExt<T> {
    // Required methods
    fn with_file_context(self, path: impl AsRef<Path>) -> Result<T>;
    fn with_config_context(self, msg: &str) -> Result<T>;
    fn with_context<F>(self, f: F) -> Result<T>
       where F: FnOnce() -> String;
    fn with_request_context(self) -> Result<T>;
    fn with_json_context(self, context: &str) -> Result<T>;
}
Expand description

Extension trait for adding context to Result types.

Required Methods§

Source

fn with_file_context(self, path: impl AsRef<Path>) -> Result<T>

Add file read context to an error.

Source

fn with_config_context(self, msg: &str) -> Result<T>

Add config parsing context to an error.

Source

fn with_context<F>(self, f: F) -> Result<T>
where F: FnOnce() -> String,

Add generic context to an error with a custom message.

Source

fn with_request_context(self) -> Result<T>

Add request building context to an error.

Source

fn with_json_context(self, context: &str) -> Result<T>

Add JSON encoding/decoding context to an error.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T, E: Display> ResultExt<T> for Result<T, E>

Source§

fn with_file_context(self, path: impl AsRef<Path>) -> Result<T>

Source§

fn with_config_context(self, msg: &str) -> Result<T>

Source§

fn with_context<F>(self, f: F) -> Result<T>
where F: FnOnce() -> String,

Source§

fn with_request_context(self) -> Result<T>

Source§

fn with_json_context(self, context: &str) -> Result<T>

Implementors§