ResultExt

Trait ResultExt 

Source
pub trait ResultExt {
    type Context: ?Sized;
    type Ok;

    // Required methods
    fn attach<A>(self, attachment: A) -> Result<Self::Ok, Report<Self::Context>>
       where A: Attachment;
    fn attach_with<A, F>(
        self,
        attachment: F,
    ) -> Result<Self::Ok, Report<Self::Context>>
       where A: Attachment,
             F: FnOnce() -> A;
    fn attach_lazy<A, F>(
        self,
        attachment: F,
    ) -> Result<Self::Ok, Report<Self::Context>>
       where A: OpaqueAttachment,
             F: FnOnce() -> A;
    fn attach_opaque<A>(
        self,
        attachment: A,
    ) -> Result<Self::Ok, Report<Self::Context>>
       where A: OpaqueAttachment;
    fn attach_opaque_with<A, F>(
        self,
        attachment: F,
    ) -> Result<Self::Ok, Report<Self::Context>>
       where A: OpaqueAttachment,
             F: FnOnce() -> A;
    fn attach_printable<A>(
        self,
        attachment: A,
    ) -> Result<Self::Ok, Report<Self::Context>>
       where A: Attachment;
    fn attach_printable_lazy<A, F>(
        self,
        attachment: F,
    ) -> Result<Self::Ok, Report<Self::Context>>
       where A: Attachment,
             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§

Source

type Context: ?Sized

The Context type of the Result.

Source

type Ok

Type of the Ok value in the Result

Required Methods§

Source

fn attach<A>(self, attachment: A) -> Result<Self::Ok, Report<Self::Context>>
where A: Attachment,

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

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

Source

fn attach_with<A, F>( self, attachment: F, ) -> Result<Self::Ok, Report<Self::Context>>
where A: Attachment, F: FnOnce() -> A,

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

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

Source

fn attach_lazy<A, F>( self, attachment: F, ) -> Result<Self::Ok, Report<Self::Context>>
where A: OpaqueAttachment, F: FnOnce() -> A,

👎Deprecated since 0.6.0: Use attach_opaque_with instead. attach_lazy was renamed to attach_opaque_with and attach_printable_lazy was renamed to attach_with
Source

fn attach_opaque<A>( self, attachment: A, ) -> Result<Self::Ok, Report<Self::Context>>

Adds a new attachment to the Report inside the Result.

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

Source

fn attach_opaque_with<A, F>( self, attachment: F, ) -> Result<Self::Ok, Report<Self::Context>>
where A: OpaqueAttachment, F: FnOnce() -> A,

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

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

Source

fn attach_printable<A>( self, attachment: A, ) -> Result<Self::Ok, Report<Self::Context>>
where A: Attachment,

👎Deprecated since 0.6.0: Use attach instead. attach was renamed to attach_opaque and attach_printable was renamed to attach
Source

fn attach_printable_lazy<A, F>( self, attachment: F, ) -> Result<Self::Ok, Report<Self::Context>>
where A: Attachment, F: FnOnce() -> A,

👎Deprecated since 0.6.0: Use attach_with instead. attach_lazy was renamed to attach_opaque_with and attach_printable_lazy was renamed to attach_with
Source

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.

Source

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§

Source§

impl<T, E> ResultExt for Result<T, E>
where E: IntoReport,

Source§

type Context = <E as IntoReport>::Context

Source§

type Ok = T

Source§

fn attach<A>(self, attachment: A) -> Result<T, Report<E::Context>>
where A: Attachment,

Source§

fn attach_with<A, F>(self, attachment: F) -> Result<T, Report<E::Context>>
where A: Attachment, F: FnOnce() -> A,

Source§

fn attach_lazy<A, F>(self, attachment: F) -> Result<T, Report<E::Context>>
where A: OpaqueAttachment, F: FnOnce() -> A,

👎Deprecated since 0.6.0: Use attach_opaque_with instead. attach_lazy was renamed to attach_opaque_with and attach_printable_lazy was renamed to attach_with
Source§

fn attach_opaque<A>(self, attachment: A) -> Result<T, Report<E::Context>>

Source§

fn attach_opaque_with<A, F>( self, attachment: F, ) -> Result<T, Report<E::Context>>
where A: OpaqueAttachment, F: FnOnce() -> A,

Source§

fn attach_printable<A>(self, attachment: A) -> Result<T, Report<E::Context>>
where A: Attachment,

👎Deprecated since 0.6.0: Use attach instead. attach was renamed to attach_opaque and attach_printable was renamed to attach
Source§

fn attach_printable_lazy<A, F>( self, attachment: F, ) -> Result<T, Report<E::Context>>
where A: Attachment, F: FnOnce() -> A,

👎Deprecated since 0.6.0: Use attach_with instead. attach_lazy was renamed to attach_opaque_with and attach_printable_lazy was renamed to attach_with
Source§

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

Source§

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

Implementors§