Skip to main content

ResultExt

Trait ResultExt 

Source
pub trait ResultExt<T>: Sealed {
    // Required methods
    fn context<C: Config, D>(
        self,
        id: C::Id,
        message: impl Into<Cow<'static, str>>,
    ) -> Result<T, C, D>;
    fn context_auto<C: Config, D>(
        self,
        message: impl Into<Cow<'static, str>>,
    ) -> Result<T, C, D>;
    fn wrap_err<C: Config, D>(self, gerr: GErr<C, D>) -> Result<T, C, D>;
}
Expand description

Extension for Result wrapping E as any error.

This is for general error, including GErr itself.

Passing GErr will be parsed as general error.

Required Methods§

Source

fn context<C: Config, D>( self, id: C::Id, message: impl Into<Cow<'static, str>>, ) -> Result<T, C, D>

Wrap E inside GErr as source with manually-set id.

Source

fn context_auto<C: Config, D>( self, message: impl Into<Cow<'static, str>>, ) -> Result<T, C, D>

Wrap E inside GErr as source with auto-generated id and code.

Source

fn wrap_err<C: Config, D>(self, gerr: GErr<C, D>) -> Result<T, C, D>

Wrap E inside GErr

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

Source§

fn context<C: Config, D>( self, id: C::Id, message: impl Into<Cow<'static, str>>, ) -> Result<T, C, D>

Source§

fn context_auto<C: Config, D>( self, message: impl Into<Cow<'static, str>>, ) -> Result<T, C, D>

Source§

fn wrap_err<C: Config, D>(self, gerr: GErr<C, D>) -> Result<T, C, D>

Implementors§