ResultContext

Trait ResultContext 

Source
pub trait ResultContext<K, T, E> {
    // Required methods
    fn kind(self, kind: K) -> UniResult<T, K>;
    fn context(self, context: impl Into<Cow<'static, str>>) -> UniResult<T, K>
       where K: Default;
    fn kind_context(
        self,
        kind: K,
        context: impl Into<Cow<'static, str>>,
    ) -> UniResult<T, K>;
    fn wrap(self) -> UniResult<T, K>
       where K: Default;

    // Provided methods
    fn kind_fn<F>(self, kind: F) -> UniResult<T, K>
       where F: FnOnce(&Self) -> K,
             Self: Sized { ... }
    fn context_fn<F, S>(self, context: F) -> UniResult<T, K>
       where F: FnOnce(&Self) -> S,
             S: Into<Cow<'static, str>>,
             K: Default,
             Self: Sized { ... }
    fn kind_context_fn<F, F2, S>(self, kind: F, context: F2) -> UniResult<T, K>
       where F: FnOnce(&Self) -> K,
             F2: FnOnce(&Self) -> S,
             S: Into<Cow<'static, str>>,
             Self: Sized { ... }
}
Expand description

A trait for wrapping an existing result error with a additional context.

Required Methods§

Source

fn kind(self, kind: K) -> UniResult<T, K>

Wraps the existing result error with the provided kind.

Source

fn context(self, context: impl Into<Cow<'static, str>>) -> UniResult<T, K>
where K: Default,

Wraps the existing result error with the provided context.

Source

fn kind_context( self, kind: K, context: impl Into<Cow<'static, str>>, ) -> UniResult<T, K>

Wraps the existing result error with the provided kind and context.

Source

fn wrap(self) -> UniResult<T, K>
where K: Default,

Wraps the existing result error with no additional context.

Provided Methods§

Source

fn kind_fn<F>(self, kind: F) -> UniResult<T, K>
where F: FnOnce(&Self) -> K, Self: Sized,

Wraps the existing result error with the provided kind.

Source

fn context_fn<F, S>(self, context: F) -> UniResult<T, K>
where F: FnOnce(&Self) -> S, S: Into<Cow<'static, str>>, K: Default, Self: Sized,

Wraps the existing result error with the provided context.

Source

fn kind_context_fn<F, F2, S>(self, kind: F, context: F2) -> UniResult<T, K>
where F: FnOnce(&Self) -> K, F2: FnOnce(&Self) -> S, S: Into<Cow<'static, str>>, Self: Sized,

Wraps the existing result error with the provided kind and context.

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<K: UniKind, T, E> ResultContext<K, T, E> for Option<T>

Source§

fn kind(self, kind: K) -> UniResult<T, K>

Source§

fn context(self, context: impl Into<Cow<'static, str>>) -> UniResult<T, K>
where K: Default,

Source§

fn kind_context( self, kind: K, context: impl Into<Cow<'static, str>>, ) -> UniResult<T, K>

Source§

fn wrap(self) -> UniResult<T, K>
where K: Default,

Source§

impl<K: UniKind, T, E: UniStdError> ResultContext<K, T, E> for Result<T, E>

Source§

fn kind(self, kind: K) -> UniResult<T, K>

Source§

fn context(self, context: impl Into<Cow<'static, str>>) -> UniResult<T, K>
where K: Default,

Source§

fn kind_context( self, kind: K, context: impl Into<Cow<'static, str>>, ) -> UniResult<T, K>

Source§

fn wrap(self) -> UniResult<T, K>
where K: Default,

Implementors§

Source§

impl<K: UniKind, K2: UniKind, T> ResultContext<K2, T, K> for UniResult<T, K>