ResExtensions

Trait ResExtensions 

Source
pub trait ResExtensions<T> {
    // Required methods
    fn extend(self, ext: Arc<dyn Extension>) -> Result<T, ErrorContext>;
    fn with_extension(
        self,
        ext: impl FnOnce() -> Arc<dyn Extension>,
    ) -> Result<T, ErrorContext>;
    fn without_extension<E: Extension>(self) -> Result<T, ErrorContext>;
}
Available on crate feature extensions only.
Expand description

A helper trait for extending error variants of Result<T, ErrorContext>

Required Methods§

Source

fn extend(self, ext: Arc<dyn Extension>) -> Result<T, ErrorContext>

Adds the given extension to the error

Source

fn with_extension( self, ext: impl FnOnce() -> Arc<dyn Extension>, ) -> Result<T, ErrorContext>

Adds a dynamically computed extension to the error

The function is only called if the result is an error variant

Source

fn without_extension<E: Extension>(self) -> Result<T, ErrorContext>

Removes any extension of a given type from the error

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> ResExtensions<T> for Result<T, ErrorContext>

Implementors§