ResultExt

Trait ResultExt 

pub trait ResultExt {
    type Context: Context;
    type Ok;

    // Required methods
    fn attach<A>(self, attachment: A) -> Result<Self::Ok, Report<Self::Context>>
       where A: Send + Sync + 'static;
    fn attach_lazy<A, F>(
        self,
        attachment: F,
    ) -> Result<Self::Ok, Report<Self::Context>>
       where A: Send + Sync + 'static,
             F: FnOnce() -> A;
    fn attach_printable<A>(
        self,
        attachment: A,
    ) -> Result<Self::Ok, Report<Self::Context>>
       where A: Display + Debug + Send + Sync + 'static;
    fn attach_printable_lazy<A, F>(
        self,
        attachment: F,
    ) -> Result<Self::Ok, Report<Self::Context>>
       where A: Display + Debug + Send + Sync + 'static,
             F: FnOnce() -> A;
    fn change_context<C>(self, context: C) -> Result<Self::Ok, Report<C>>
       where C: Context;
    fn change_context_lazy<C, F>(
        self,
        context: F,
    ) -> Result<Self::Ok, Report<C>>
       where C: Context,
             F: FnOnce() -> C;
}
Expand description

Extension trait for Result to provide context information on Reports.

Required Associated Types§

type Context: Context

The [Context] type of the [Result].

type Ok

Type of the Ok value in the [Result]

Required Methods§

fn attach<A>(self, attachment: A) -> Result<Self::Ok, Report<Self::Context>>
where A: Send + Sync + 'static,

Adds a new attachment to the Report inside the [Result].

Applies Report::attach on the Err variant, refer to it for more information.

fn attach_lazy<A, F>( self, attachment: F, ) -> Result<Self::Ok, Report<Self::Context>>
where A: Send + Sync + 'static, F: FnOnce() -> A,

Lazily adds a new attachment to the Report inside the [Result].

Applies Report::attach on the Err variant, refer to it for more information.

fn attach_printable<A>( self, attachment: A, ) -> Result<Self::Ok, Report<Self::Context>>
where A: Display + Debug + Send + Sync + 'static,

Adds a new printable attachment to the Report inside the [Result].

Applies Report::attach_printable on the Err variant, refer to it for more information.

fn attach_printable_lazy<A, F>( self, attachment: F, ) -> Result<Self::Ok, Report<Self::Context>>
where A: Display + Debug + Send + Sync + 'static, F: FnOnce() -> A,

Lazily adds a new printable attachment to the Report inside the [Result].

Applies Report::attach_printable on the Err variant, refer to it for more information.

fn change_context<C>(self, context: C) -> Result<Self::Ok, Report<C>>
where C: Context,

Changes the context of the Report inside the [Result].

Applies Report::change_context on the Err variant, refer to it for more information.

fn change_context_lazy<C, F>(self, context: F) -> Result<Self::Ok, Report<C>>
where C: Context, F: FnOnce() -> C,

Lazily changes the context of the Report inside the [Result].

Applies Report::change_context on the Err variant, refer to it for more information.

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§

§

impl<T, C> ResultExt for Result<T, Report<C>>
where C: Context,

§

type Context = C

§

type Ok = T

§

fn attach<A>(self, attachment: A) -> Result<T, Report<C>>
where A: Send + Sync + 'static,

§

fn attach_lazy<A, F>(self, attachment: F) -> Result<T, Report<C>>
where A: Send + Sync + 'static, F: FnOnce() -> A,

§

fn attach_printable<A>(self, attachment: A) -> Result<T, Report<C>>
where A: Display + Debug + Send + Sync + 'static,

§

fn attach_printable_lazy<A, F>(self, attachment: F) -> Result<T, Report<C>>
where A: Display + Debug + Send + Sync + 'static, F: FnOnce() -> A,

§

fn change_context<C2>(self, context: C2) -> Result<T, Report<C2>>
where C2: Context,

§

fn change_context_lazy<C2, F>(self, context: F) -> Result<T, Report<C2>>
where C2: Context, F: FnOnce() -> C2,

§

impl<T, C> ResultExt for Result<T, C>
where C: Context,

§

type Context = C

§

type Ok = T

§

fn attach<A>(self, attachment: A) -> Result<T, Report<C>>
where A: Send + Sync + 'static,

§

fn attach_lazy<A, F>(self, attachment: F) -> Result<T, Report<C>>
where A: Send + Sync + 'static, F: FnOnce() -> A,

§

fn attach_printable<A>(self, attachment: A) -> Result<T, Report<C>>
where A: Display + Debug + Send + Sync + 'static,

§

fn attach_printable_lazy<A, F>(self, attachment: F) -> Result<T, Report<C>>
where A: Display + Debug + Send + Sync + 'static, F: FnOnce() -> A,

§

fn change_context<C2>(self, context: C2) -> Result<T, Report<C2>>
where C2: Context,

§

fn change_context_lazy<C2, F>(self, context: F) -> Result<T, Report<C2>>
where C2: Context, F: FnOnce() -> C2,

Implementors§