ResContext

Trait ResContext 

Source
pub trait ResContext<T, E> {
    // Required methods
    fn context<M>(self, msg: M) -> Result<T, ErrorContext>
       where M: Into<SharedString>;
    fn with_context<M, F>(self, f: F) -> Result<T, ErrorContext>
       where M: Into<SharedString>,
             F: FnOnce() -> M;
}
Expand description

A helper trait for annotating result errors and empty options

Required Methods§

Source

fn context<M>(self, msg: M) -> Result<T, ErrorContext>
where M: Into<SharedString>,

Map the error into a new cloneable ErrorContext error, annotated with a specified context message

Source

fn with_context<M, F>(self, f: F) -> Result<T, ErrorContext>
where M: Into<SharedString>, F: FnOnce() -> M,

Map the error into a new cloneable ErrorContext error, annotated with a dynamically computed context message

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> ResContext<T, Infallible> for Option<T>

Source§

fn context<M>(self, msg: M) -> Result<T, ErrorContext>
where M: Into<SharedString>,

Source§

fn with_context<M, F>(self, f: F) -> Result<T, ErrorContext>
where M: Into<SharedString>, F: FnOnce() -> M,

Source§

impl<T, E> ResContext<T, E> for Result<T, E>
where E: ErrContext,

Source§

fn context<M>(self, msg: M) -> Result<T, ErrorContext>
where M: Into<SharedString>,

Source§

fn with_context<M, F>(self, f: F) -> Result<T, ErrorContext>
where M: Into<SharedString>, F: FnOnce() -> M,

Implementors§