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§
Sourcefn with_file_context(self, path: impl AsRef<Path>) -> Result<T>
fn with_file_context(self, path: impl AsRef<Path>) -> Result<T>
Add file read context to an error.
Sourcefn with_config_context(self, msg: &str) -> Result<T>
fn with_config_context(self, msg: &str) -> Result<T>
Add config parsing context to an error.
Sourcefn with_context<F>(self, f: F) -> Result<T>
fn with_context<F>(self, f: F) -> Result<T>
Add generic context to an error with a custom message.
Sourcefn with_request_context(self) -> Result<T>
fn with_request_context(self) -> Result<T>
Add request building context to an error.
Sourcefn with_json_context(self, context: &str) -> Result<T>
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".