MapToErr

Trait MapToErr 

Source
pub trait MapToErr<T> {
    // Required methods
    fn map_to_internal_err(self, reason: &'static str) -> Result<T>;
    fn map_to_err(
        self,
        code: impl ErrorInfo + Send + Sync + 'static,
    ) -> Result<T>;
    fn map_to_err_with(
        self,
        code: impl ErrorInfo + Send + Sync + 'static,
        reason: &'static str,
    ) -> Result<T>;
}
Expand description

Utility trait to map any Result<T,E> to a Result<T, Box<Error>>

Required Methods§

Source

fn map_to_internal_err(self, reason: &'static str) -> Result<T>

Maps the error to an internal server error

Source

fn map_to_err(self, code: impl ErrorInfo + Send + Sync + 'static) -> Result<T>

Maps the error to the given one

Source

fn map_to_err_with( self, code: impl ErrorInfo + Send + Sync + 'static, reason: &'static str, ) -> Result<T>

Maps the error to the given one with a reason

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.

Implementors§

Source§

impl<T, E: Display + Send + Sync + 'static> MapToErr<T> for Result<T, E>