Skip to main content

CtxDagChain

Struct CtxDagChain 

Source
pub struct CtxDagChain<C, In, Out, Chain> { /* private fields */ }
Expand description

Main chain builder for a context-aware DAG.

Chain implements [CtxChainCall<C, E, Out = Out>].

Implementations§

Source§

impl<C, In, Out: 'static, Chain> CtxDagChain<C, In, Out, Chain>

Source

pub fn fork(self) -> CtxDagChainFork<C, In, Out, Chain, ()>

Enter fork mode. Subsequent .arm() calls add parallel branches.

Source§

impl<C, In, Chain: CtxChainCall<C, In, Out = ()>> CtxDagChain<C, In, (), Chain>

Source

pub fn build(self) -> CtxDag<C, In, Chain>

Finalize into a CtxDag that implements [CtxStepCall].

Source§

impl<C, In, Chain: CtxChainCall<C, In, Out = Option<()>>> CtxDagChain<C, In, Option<()>, Chain>

Source

pub fn build(self) -> CtxDag<C, In, CtxDiscardOptionNode<Chain>>

Finalize into a CtxDag, discarding the Option<()>.

Source§

impl<Ctx, In, Out: 'static, Chain> CtxDagChain<Ctx, In, Out, Chain>

Source

pub fn then<NewOut, Params, S>( self, f: S, registry: &Registry, ) -> CtxDagChain<Ctx, In, NewOut, CtxDagThenNode<Chain, S::Step, NewOut>>
where NewOut: 'static, S: IntoCtxStep<Ctx, &'static Out, NewOut, Params>, S::Step: for<'a> CtxStepCall<Ctx, &'a Out, Out = NewOut> + 'static,

Append a step. The step receives &Out by reference.

Source

pub fn guard<Params, S: IntoCtxRefStep<Ctx, Out, bool, Params>>( self, f: S, registry: &Registry, ) -> CtxDagChain<Ctx, In, Option<Out>, CtxGuardNode<Chain, S::Step>>

Conditionally wrap the output in Option.

Source

pub fn tap<Params, S: IntoCtxRefStep<Ctx, Out, (), Params>>( self, f: S, registry: &Registry, ) -> CtxDagChain<Ctx, In, Out, CtxTapNode<Chain, S::Step>>

Observe the current value without consuming or changing it.

Source§

impl<Ctx, In, T: 'static, Chain> CtxDagChain<Ctx, In, Option<T>, Chain>

Source

pub fn map<U, Params, S>( self, f: S, registry: &Registry, ) -> CtxDagChain<Ctx, In, Option<U>, CtxDagMapOptionNode<Chain, S::Step, U>>
where U: 'static, S: IntoCtxStep<Ctx, &'static T, U, Params>, S::Step: for<'x> CtxStepCall<Ctx, &'x T, Out = U>,

Transform the inner value. Step not called on None.

Source

pub fn and_then<U, Params, S>( self, f: S, registry: &Registry, ) -> CtxDagChain<Ctx, In, Option<U>, CtxDagAndThenOptionNode<Chain, S::Step, U>>
where U: 'static, S: IntoCtxStep<Ctx, &'static T, Option<U>, Params>, S::Step: for<'x> CtxStepCall<Ctx, &'x T, Out = Option<U>>,

Short-circuits on None. std: Option::and_then

Source

pub fn on_none<Params, S: IntoCtxProducer<Ctx, (), Params>>( self, f: S, registry: &Registry, ) -> CtxDagChain<Ctx, In, Option<T>, CtxOnNoneNode<Chain, S::Step>>

Side effect on None.

Source

pub fn filter<Params, S: IntoCtxRefStep<Ctx, T, bool, Params>>( self, f: S, registry: &Registry, ) -> CtxDagChain<Ctx, In, Option<T>, CtxFilterNode<Chain, S::Step>>

Keep value if predicate holds. std: Option::filter

Source

pub fn inspect<Params, S: IntoCtxRefStep<Ctx, T, (), Params>>( self, f: S, registry: &Registry, ) -> CtxDagChain<Ctx, In, Option<T>, CtxInspectOptionNode<Chain, S::Step>>

Side effect on Some value. std: Option::inspect

Source

pub fn ok_or<E: Clone>( self, err: E, ) -> CtxDagChain<Ctx, In, Result<T, E>, CtxOkOrNode<Chain, E>>

None becomes Err(err). std: Option::ok_or

Source

pub fn unwrap_or( self, default: T, ) -> CtxDagChain<Ctx, In, T, CtxUnwrapOrOptionNode<Chain, T>>
where T: Clone,

Exit Option — None becomes the default value.

Source

pub fn unwrap_or_else<Params, S: IntoCtxProducer<Ctx, T, Params>>( self, f: S, registry: &Registry, ) -> CtxDagChain<Ctx, In, T, CtxUnwrapOrElseOptionNode<Chain, S::Step>>

Exit Option — None becomes f().

Source§

impl<Ctx, In, T: 'static, Err: 'static, Chain> CtxDagChain<Ctx, In, Result<T, Err>, Chain>

Source

pub fn map<U, Params, S>( self, f: S, registry: &Registry, ) -> CtxDagChain<Ctx, In, Result<U, Err>, CtxDagMapResultNode<Chain, S::Step, U>>
where U: 'static, S: IntoCtxStep<Ctx, &'static T, U, Params>, S::Step: for<'x> CtxStepCall<Ctx, &'x T, Out = U>,

Transform the Ok value. Step not called on Err.

Source

pub fn and_then<U, Params, S>( self, f: S, registry: &Registry, ) -> CtxDagChain<Ctx, In, Result<U, Err>, CtxDagAndThenResultNode<Chain, S::Step, U>>
where U: 'static, S: IntoCtxStep<Ctx, &'static T, Result<U, Err>, Params>, S::Step: for<'x> CtxStepCall<Ctx, &'x T, Out = Result<U, Err>>,

Short-circuits on Err. std: Result::and_then

Source

pub fn catch<Params, S>( self, f: S, registry: &Registry, ) -> CtxDagChain<Ctx, In, Option<T>, CtxDagCatchNode<Chain, S::Step>>
where S: IntoCtxStep<Ctx, &'static Err, (), Params>, S::Step: for<'x> CtxStepCall<Ctx, &'x Err, Out = ()>,

Handle error and transition to Option.

Source

pub fn map_err<E2, Params, S: IntoCtxStep<Ctx, Err, E2, Params>>( self, f: S, registry: &Registry, ) -> CtxDagChain<Ctx, In, Result<T, E2>, CtxMapErrNode<Chain, S::Step>>

Transform the error. std: Result::map_err

Source

pub fn inspect<Params, S: IntoCtxRefStep<Ctx, T, (), Params>>( self, f: S, registry: &Registry, ) -> CtxDagChain<Ctx, In, Result<T, Err>, CtxInspectResultNode<Chain, S::Step>>

Side effect on Ok value. std: Result::inspect

Source

pub fn inspect_err<Params, S: IntoCtxRefStep<Ctx, Err, (), Params>>( self, f: S, registry: &Registry, ) -> CtxDagChain<Ctx, In, Result<T, Err>, CtxInspectErrNode<Chain, S::Step>>

Side effect on Err. std: Result::inspect_err

Source

pub fn ok(self) -> CtxDagChain<Ctx, In, Option<T>, CtxOkNode<Chain>>

Discard error, enter Option land. std: Result::ok

Source

pub fn unwrap_or( self, default: T, ) -> CtxDagChain<Ctx, In, T, CtxUnwrapOrResultNode<Chain, T>>
where T: Clone,

Exit Result — Err becomes the default value.

Auto Trait Implementations§

§

impl<C, In, Out, Chain> Freeze for CtxDagChain<C, In, Out, Chain>
where Chain: Freeze,

§

impl<C, In, Out, Chain> RefUnwindSafe for CtxDagChain<C, In, Out, Chain>
where Chain: RefUnwindSafe,

§

impl<C, In, Out, Chain> Send for CtxDagChain<C, In, Out, Chain>
where Chain: Send,

§

impl<C, In, Out, Chain> Sync for CtxDagChain<C, In, Out, Chain>
where Chain: Sync,

§

impl<C, In, Out, Chain> Unpin for CtxDagChain<C, In, Out, Chain>
where Chain: Unpin,

§

impl<C, In, Out, Chain> UnsafeUnpin for CtxDagChain<C, In, Out, Chain>
where Chain: UnsafeUnpin,

§

impl<C, In, Out, Chain> UnwindSafe for CtxDagChain<C, In, Out, Chain>
where Chain: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.