Trait ResultExt

Source
pub trait ResultExt<T> {
    // Required methods
    fn with_context<F>(self, f: F) -> Result<T>
       where F: FnOnce() -> String;
    fn with_source(self, source: impl Into<String>) -> Result<T>;
    fn with_plugin(self, plugin_id: impl Into<String>) -> Result<T>;
    fn with_correlation(self, correlation_id: Uuid) -> Result<T>;
}
Expand description

Extension trait for Results to add context

Required Methods§

Source

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

Adds context to an error

Source

fn with_source(self, source: impl Into<String>) -> Result<T>

Sets the error source

Source

fn with_plugin(self, plugin_id: impl Into<String>) -> Result<T>

Sets the plugin ID

Source

fn with_correlation(self, correlation_id: Uuid) -> Result<T>

Sets the correlation ID

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<T> for Result<T, E>
where E: Error + Send + Sync + 'static,

Source§

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

Source§

fn with_source(self, source: impl Into<String>) -> Result<T>

Source§

fn with_plugin(self, plugin_id: impl Into<String>) -> Result<T>

Source§

fn with_correlation(self, correlation_id: Uuid) -> Result<T>

Implementors§