ConvertResult

Trait ConvertResult 

Source
pub trait ConvertResult<T, E>: Sized {
    // Required methods
    fn context<C>(self, context: C) -> Result<T, NeuErr>
       where C: Into<Cow<'static, str>>;
    fn context_with<F, C>(self, context_fn: F) -> Result<T, NeuErr>
       where F: FnOnce(&E) -> C,
             C: Into<Cow<'static, str>>;
    fn attach<C>(self, context: C) -> Result<T, NeuErr>
       where C: AnyDebugSendSync + 'static;
    fn attach_with<F, C>(self, context_fn: F) -> Result<T, NeuErr>
       where F: FnOnce(&E) -> C,
             C: AnyDebugSendSync + 'static;
    fn attach_override<C>(self, context: C) -> Result<T, NeuErr>
       where C: AnyDebugSendSync + 'static;
    fn attach_override_with<F, C>(self, context_fn: F) -> Result<T, NeuErr>
       where F: FnOnce(&E) -> C,
             C: AnyDebugSendSync + 'static;
}
Expand description

Helper on Results with external Errors for conversion to our NeuErr.

Required Methods§

Source

fn context<C>(self, context: C) -> Result<T, NeuErr>
where C: Into<Cow<'static, str>>,

Add human context to the error.

Source

fn context_with<F, C>(self, context_fn: F) -> Result<T, NeuErr>
where F: FnOnce(&E) -> C, C: Into<Cow<'static, str>>,

Add human context to the error via a closure.

Source

fn attach<C>(self, context: C) -> Result<T, NeuErr>
where C: AnyDebugSendSync + 'static,

Add machine context to the error.

This will not override existing attachments. If you want to replace and override any existing attachments of the same type, use attach_override instead.

Source

fn attach_with<F, C>(self, context_fn: F) -> Result<T, NeuErr>
where F: FnOnce(&E) -> C, C: AnyDebugSendSync + 'static,

Add machine context to the error via a closure.

This will not override existing attachments. If you want to replace and override any existing attachments of the same type, use attach_override instead.

Source

fn attach_override<C>(self, context: C) -> Result<T, NeuErr>
where C: AnyDebugSendSync + 'static,

Set machine context in the error.

This will override existing attachments of the same type. If you want to add attachments of the same type, use attach instead.

Source

fn attach_override_with<F, C>(self, context_fn: F) -> Result<T, NeuErr>
where F: FnOnce(&E) -> C, C: AnyDebugSendSync + 'static,

Set machine context in the error via a closure.

This will override existing attachments of the same type. If you want to add attachments of the same type, use attach instead.

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, E> ConvertResult<T, E> for Result<T, E>
where E: ErrorSendSync + 'static,

Source§

fn context<C>(self, context: C) -> Result<T, NeuErr>
where C: Into<Cow<'static, str>>,

Source§

fn context_with<F, C>(self, context_fn: F) -> Result<T, NeuErr>
where F: FnOnce(&E) -> C, C: Into<Cow<'static, str>>,

Source§

fn attach<C>(self, context: C) -> Result<T, NeuErr>
where C: AnyDebugSendSync + 'static,

Source§

fn attach_with<F, C>(self, context_fn: F) -> Result<T, NeuErr>
where F: FnOnce(&E) -> C, C: AnyDebugSendSync + 'static,

Source§

fn attach_override<C>(self, context: C) -> Result<T, NeuErr>
where C: AnyDebugSendSync + 'static,

Source§

fn attach_override_with<F, C>(self, context_fn: F) -> Result<T, NeuErr>
where F: FnOnce(&E) -> C, C: AnyDebugSendSync + 'static,

Implementors§