Skip to main content

HandleExt

Trait HandleExt 

Source
pub trait HandleExt<T> {
    // Required methods
    fn then<U, F>(self, f: F) -> Result<U>
       where F: FnOnce(T) -> Result<U>;
    fn then_with<U, F>(self, ctx: impl Into<String>, f: F) -> Result<U>
       where F: FnOnce(T) -> Result<U>;
    fn context(self, ctx: impl Into<String>) -> Self;
    fn attach(self, key: &'static str, val: impl IntoValue) -> Self;
}
Expand description

Extension trait for adding context to Result<T, Handled>.

Required Methods§

Source

fn then<U, F>(self, f: F) -> Result<U>
where F: FnOnce(T) -> Result<U>,

Chain another operation, adding a frame on error.

Source

fn then_with<U, F>(self, ctx: impl Into<String>, f: F) -> Result<U>
where F: FnOnce(T) -> Result<U>,

Chain another operation with context message.

Source

fn context(self, ctx: impl Into<String>) -> Self

Add context message to error.

Source

fn attach(self, key: &'static str, val: impl IntoValue) -> Self

Add key-value attachment to error with typed value.

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> HandleExt<T> for Result<T>