Skip to main content

BuilderExt

Trait BuilderExt 

Source
pub trait BuilderExt: Sized {
    type Result<E>;
    type E;
    type S: State + ?Sized;
    type F: PayloadFn;
    type L: Literal + ?Sized;

    // Required methods
    fn with_context_ty<L>(
        self,
    ) -> Self::Result<Builder<Self::E, Self::S, Self::F, L>>
       where L: Context;
    fn with_state<S>(
        self,
        state: S,
    ) -> Self::Result<Builder<Self::E, S, Self::F, Self::L>>
       where S: State + Sized;
    fn with_payload_fn<F>(
        self,
        payload_fn: F,
    ) -> Self::Result<Builder<Self::E, Self::S, F, Self::L>>
       where F: PayloadFn;

    // Provided methods
    fn with_context<L>(
        self,
        _ty: L,
    ) -> Self::Result<Builder<Self::E, Self::S, Self::F, L>>
       where L: Context { ... }
    fn with_payload<P>(
        self,
        payload: P,
    ) -> Self::Result<Builder<Self::E, Self::S, Immediate<P>, Self::L>>
       where P: Display + Send + Sync + 'static { ... }
}
Expand description

Extension trait for attaching context, state, or payload to an existing error.

Required Associated Types§

Required Methods§

Source

fn with_context_ty<L>( self, ) -> Self::Result<Builder<Self::E, Self::S, Self::F, L>>
where L: Context,

Attaches a literal context identified by its type.

Source

fn with_state<S>( self, state: S, ) -> Self::Result<Builder<Self::E, S, Self::F, Self::L>>
where S: State + Sized,

Attaches a typed state.

Source

fn with_payload_fn<F>( self, payload_fn: F, ) -> Self::Result<Builder<Self::E, Self::S, F, Self::L>>
where F: PayloadFn,

Attaches a lazily-evaluated payload.

Provided Methods§

Source

fn with_context<L>( self, _ty: L, ) -> Self::Result<Builder<Self::E, Self::S, Self::F, L>>
where L: Context,

Attaches a static literal context.

For dynamic content, use with_payload instead. It’s encouraged to just use .with_payload(".."), since in most cases we are wrapping a source error and the allocation cost is already paid.

Source

fn with_payload<P>( self, payload: P, ) -> Self::Result<Builder<Self::E, Self::S, Immediate<P>, Self::L>>
where P: Display + Send + Sync + 'static,

Attaches a displayable payload.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T, E1, S1, F1, L1> BuilderExt for Result<T, Builder<E1, S1, F1, L1>>
where F1: PayloadFn, S1: State + ?Sized, L1: Literal + ?Sized,

Source§

type Result<E> = Result<T, E>

Source§

type E = E1

Source§

type S = S1

Source§

type F = F1

Source§

type L = L1

Source§

fn with_context_ty<L>( self, ) -> Self::Result<Builder<Self::E, Self::S, Self::F, L>>
where L: Context,

Source§

fn with_state<S>( self, state: S, ) -> Self::Result<Builder<Self::E, S, Self::F, Self::L>>
where S: State,

Source§

fn with_payload_fn<F>( self, payload_fn: F, ) -> Self::Result<Builder<Self::E, Self::S, F, Self::L>>
where F: PayloadFn,

Source§

impl<T, E1> BuilderExt for Result<T, E1>
where E1: Error + Send + Sync + 'static,

Source§

type Result<E> = Result<T, E>

Source§

type E = E1

Source§

type S = Stateless

Source§

type F = Immediate<Empty>

Source§

type L = Blank

Source§

fn with_context_ty<L>( self, ) -> Self::Result<Builder<Self::E, Self::S, Self::F, L>>
where L: Context,

Source§

fn with_state<S>( self, state: S, ) -> Self::Result<Builder<Self::E, S, Self::F, Self::L>>
where S: State + Sized,

Source§

fn with_payload_fn<F>( self, payload_fn: F, ) -> Self::Result<Builder<Self::E, Self::S, F, Self::L>>
where F: PayloadFn,

Source§

impl<T, S1> BuilderExt for Result<T, Error<S1>>
where S1: State + ?Sized,

Source§

type Result<E> = Result<T, E>

Source§

type E = Error<S1>

Source§

type S = Stateless

Source§

type F = Immediate<Empty>

Source§

type L = Blank

Source§

fn with_context_ty<L>( self, ) -> Self::Result<Builder<Self::E, Self::S, Self::F, L>>
where L: Context,

Source§

fn with_state<S>( self, state: S, ) -> Self::Result<Builder<Self::E, S, Self::F, Self::L>>
where S: State,

Source§

fn with_payload_fn<F>( self, payload_fn: F, ) -> Self::Result<Builder<Self::E, Self::S, F, Self::L>>
where F: PayloadFn,

Source§

impl<T> BuilderExt for Option<T>

Source§

type Result<E> = Result<T, E>

Source§

type E = Nae

Source§

type S = Stateless

Source§

type F = Immediate<Empty>

Source§

type L = Blank

Source§

fn with_context_ty<L>( self, ) -> Self::Result<Builder<Self::E, Self::S, Self::F, L>>
where L: Context,

Source§

fn with_state<S>( self, state: S, ) -> Self::Result<Builder<Self::E, S, Self::F, Self::L>>
where S: State,

Source§

fn with_payload_fn<F>( self, payload_fn: F, ) -> Self::Result<Builder<Self::E, Self::S, F, Self::L>>
where F: PayloadFn,

Implementors§

Source§

impl<E1, S1, F1, L1> BuilderExt for Builder<E1, S1, F1, L1>
where F1: PayloadFn, S1: State + ?Sized, L1: Literal + ?Sized,

Source§

type Result<E> = E

Source§

type E = E1

Source§

type S = S1

Source§

type F = F1

Source§

type L = L1