pub struct DagChain<E, Out, Chain> { /* private fields */ }Expand description
Main chain builder for a typed DAG.
Chain implements [ChainCall<E, Out = Out>] — a named node type
representing all steps composed so far. No closures, no use<>.
Implementations§
Source§impl<E, Out: 'static, Chain> DagChain<E, Out, Chain>
impl<E, Out: 'static, Chain> DagChain<E, Out, Chain>
Sourcepub fn fork(self) -> DagChainFork<E, Out, Chain, ()>
pub fn fork(self) -> DagChainFork<E, Out, Chain, ()>
Enter fork mode. Subsequent .arm() calls add parallel branches.
Source§impl<E, Chain> DagChain<E, (), Chain>
impl<E, Chain> DagChain<E, (), Chain>
Sourcepub fn build(self) -> Dag<Chain>
pub fn build(self) -> Dag<Chain>
Finalize into a Dag that implements Handler<E>.
Only available when the chain ends with () or Option<()>.
If your DAG produces a value, add a final .then() that consumes
the output.
Source§impl<E, Out: 'static, Chain> DagChain<E, Out, Chain>
impl<E, Out: 'static, Chain> DagChain<E, Out, Chain>
Sourcepub fn then<NewOut, Params, S>(
self,
f: S,
registry: &Registry,
) -> DagChain<E, NewOut, DagThenNode<Chain, S::Step, NewOut>>where
NewOut: 'static,
S: IntoStep<&'static Out, NewOut, Params>,
S::Step: for<'a> StepCall<&'a Out, Out = NewOut>,
pub fn then<NewOut, Params, S>(
self,
f: S,
registry: &Registry,
) -> DagChain<E, NewOut, DagThenNode<Chain, S::Step, NewOut>>where
NewOut: 'static,
S: IntoStep<&'static Out, NewOut, Params>,
S::Step: for<'a> StepCall<&'a Out, Out = NewOut>,
Append a step. The step receives &Out by reference.
Sourcepub fn dispatch<H: Handler<Out>>(
self,
handler: H,
) -> DagChain<E, (), DispatchNode<Chain, H>>
pub fn dispatch<H: Handler<Out>>( self, handler: H, ) -> DagChain<E, (), DispatchNode<Chain, H>>
Dispatch output to a Handler<Out>.
Sourcepub fn guard<Params, S: IntoRefStep<Out, bool, Params>>(
self,
f: S,
registry: &Registry,
) -> DagChain<E, Option<Out>, GuardNode<Chain, S::Step>>
pub fn guard<Params, S: IntoRefStep<Out, bool, Params>>( self, f: S, registry: &Registry, ) -> DagChain<E, Option<Out>, GuardNode<Chain, S::Step>>
Conditionally wrap the output in Option.
Sourcepub fn view<V: View<Out>>(self) -> ViewScope<E, Out, V, Chain, ()>
pub fn view<V: View<Out>>(self) -> ViewScope<E, Out, V, Chain, ()>
Open a view scope. Steps inside operate on a read-only
view constructed from the event. Close with .end_view().
Sourcepub fn tap<Params, S: IntoRefStep<Out, (), Params>>(
self,
f: S,
registry: &Registry,
) -> DagChain<E, Out, TapNode<Chain, S::Step>>
pub fn tap<Params, S: IntoRefStep<Out, (), Params>>( self, f: S, registry: &Registry, ) -> DagChain<E, Out, TapNode<Chain, S::Step>>
Observe the current value without consuming or changing it.
Sourcepub fn route<NewOut, C0, C1, Params, Pred: IntoRefStep<Out, bool, Params>>(
self,
pred: Pred,
registry: &Registry,
on_true: DagArm<Out, NewOut, C0>,
on_false: DagArm<Out, NewOut, C1>,
) -> DagChain<E, NewOut, DagRouteNode<Chain, Pred::Step, C0, C1, NewOut>>
pub fn route<NewOut, C0, C1, Params, Pred: IntoRefStep<Out, bool, Params>>( self, pred: Pred, registry: &Registry, on_true: DagArm<Out, NewOut, C0>, on_false: DagArm<Out, NewOut, C1>, ) -> DagChain<E, NewOut, DagRouteNode<Chain, Pred::Step, C0, C1, NewOut>>
Binary conditional routing. Both arms borrow &Out.
Sourcepub fn tee<C>(
self,
side: DagArm<Out, (), C>,
) -> DagChain<E, Out, TeeNode<Chain, C>>
pub fn tee<C>( self, side: DagArm<Out, (), C>, ) -> DagChain<E, Out, TeeNode<Chain, C>>
Fork off a multi-step side-effect chain.
Sourcepub fn scan<Acc, NewOut, Params, S>(
self,
initial: Acc,
f: S,
registry: &Registry,
) -> DagChain<E, NewOut, RefScanNode<Chain, S::Step, Acc>>where
Acc: 'static,
NewOut: 'static,
S: IntoRefScanStep<Acc, Out, NewOut, Params>,
pub fn scan<Acc, NewOut, Params, S>(
self,
initial: Acc,
f: S,
registry: &Registry,
) -> DagChain<E, NewOut, RefScanNode<Chain, S::Step, Acc>>where
Acc: 'static,
NewOut: 'static,
S: IntoRefScanStep<Acc, Out, NewOut, Params>,
Scan with persistent accumulator. The step receives
&mut Acc and &Out by reference.
Source§impl<E, Chain> DagChain<E, bool, Chain>
impl<E, Chain> DagChain<E, bool, Chain>
Sourcepub fn and<Params, S: IntoProducer<bool, Params>>(
self,
f: S,
registry: &Registry,
) -> DagChain<E, bool, AndBoolNode<Chain, S::Step>>
pub fn and<Params, S: IntoProducer<bool, Params>>( self, f: S, registry: &Registry, ) -> DagChain<E, bool, AndBoolNode<Chain, S::Step>>
Short-circuit AND with a second boolean.
Source§impl<E, T: 'static, Chain> DagChain<E, Option<T>, Chain>
impl<E, T: 'static, Chain> DagChain<E, Option<T>, Chain>
Sourcepub fn map<U, Params, S: IntoStep<&'static T, U, Params>>(
self,
f: S,
registry: &Registry,
) -> DagChain<E, Option<U>, DagMapOptionNode<Chain, S::Step, U>>
pub fn map<U, Params, S: IntoStep<&'static T, U, Params>>( self, f: S, registry: &Registry, ) -> DagChain<E, Option<U>, DagMapOptionNode<Chain, S::Step, U>>
Transform the inner value. Step not called on None.
Sourcepub fn and_then<U, Params, S: IntoStep<&'static T, Option<U>, Params>>(
self,
f: S,
registry: &Registry,
) -> DagChain<E, Option<U>, DagAndThenOptionNode<Chain, S::Step, U>>
pub fn and_then<U, Params, S: IntoStep<&'static T, Option<U>, Params>>( self, f: S, registry: &Registry, ) -> DagChain<E, Option<U>, DagAndThenOptionNode<Chain, S::Step, U>>
Short-circuits on None. std: Option::and_then
Sourcepub fn on_none<Params, S: IntoProducer<(), Params>>(
self,
f: S,
registry: &Registry,
) -> DagChain<E, Option<T>, OnNoneNode<Chain, S::Step>>
pub fn on_none<Params, S: IntoProducer<(), Params>>( self, f: S, registry: &Registry, ) -> DagChain<E, Option<T>, OnNoneNode<Chain, S::Step>>
Side effect on None.
Sourcepub fn filter<Params, S: IntoRefStep<T, bool, Params>>(
self,
f: S,
registry: &Registry,
) -> DagChain<E, Option<T>, FilterNode<Chain, S::Step>>
pub fn filter<Params, S: IntoRefStep<T, bool, Params>>( self, f: S, registry: &Registry, ) -> DagChain<E, Option<T>, FilterNode<Chain, S::Step>>
Keep value if predicate holds. std: Option::filter
Sourcepub fn inspect<Params, S: IntoRefStep<T, (), Params>>(
self,
f: S,
registry: &Registry,
) -> DagChain<E, Option<T>, InspectOptionNode<Chain, S::Step>>
pub fn inspect<Params, S: IntoRefStep<T, (), Params>>( self, f: S, registry: &Registry, ) -> DagChain<E, Option<T>, InspectOptionNode<Chain, S::Step>>
Side effect on Some value. std: Option::inspect
Sourcepub fn ok_or<Err: Clone>(
self,
err: Err,
) -> DagChain<E, Result<T, Err>, OkOrNode<Chain, Err>>
pub fn ok_or<Err: Clone>( self, err: Err, ) -> DagChain<E, Result<T, Err>, OkOrNode<Chain, Err>>
None becomes Err(err). std: Option::ok_or
Sourcepub fn ok_or_else<Err, Params, S: IntoProducer<Err, Params>>(
self,
f: S,
registry: &Registry,
) -> DagChain<E, Result<T, Err>, OkOrElseNode<Chain, S::Step>>
pub fn ok_or_else<Err, Params, S: IntoProducer<Err, Params>>( self, f: S, registry: &Registry, ) -> DagChain<E, Result<T, Err>, OkOrElseNode<Chain, S::Step>>
None becomes Err(f()). std: Option::ok_or_else
Sourcepub fn unwrap_or(
self,
default: T,
) -> DagChain<E, T, UnwrapOrOptionNode<Chain, T>>where
T: Clone,
pub fn unwrap_or(
self,
default: T,
) -> DagChain<E, T, UnwrapOrOptionNode<Chain, T>>where
T: Clone,
Exit Option — None becomes the default value.
Sourcepub fn unwrap_or_else<Params, S: IntoProducer<T, Params>>(
self,
f: S,
registry: &Registry,
) -> DagChain<E, T, UnwrapOrElseOptionNode<Chain, S::Step>>
pub fn unwrap_or_else<Params, S: IntoProducer<T, Params>>( self, f: S, registry: &Registry, ) -> DagChain<E, T, UnwrapOrElseOptionNode<Chain, S::Step>>
Exit Option — None becomes f().
Source§impl<E, T: 'static, Err: 'static, Chain> DagChain<E, Result<T, Err>, Chain>
impl<E, T: 'static, Err: 'static, Chain> DagChain<E, Result<T, Err>, Chain>
Sourcepub fn map<U, Params, S: IntoStep<&'static T, U, Params>>(
self,
f: S,
registry: &Registry,
) -> DagChain<E, Result<U, Err>, DagMapResultNode<Chain, S::Step, U>>
pub fn map<U, Params, S: IntoStep<&'static T, U, Params>>( self, f: S, registry: &Registry, ) -> DagChain<E, Result<U, Err>, DagMapResultNode<Chain, S::Step, U>>
Transform the Ok value. Step not called on Err.
Sourcepub fn and_then<U, Params, S: IntoStep<&'static T, Result<U, Err>, Params>>(
self,
f: S,
registry: &Registry,
) -> DagChain<E, Result<U, Err>, DagAndThenResultNode<Chain, S::Step, U>>
pub fn and_then<U, Params, S: IntoStep<&'static T, Result<U, Err>, Params>>( self, f: S, registry: &Registry, ) -> DagChain<E, Result<U, Err>, DagAndThenResultNode<Chain, S::Step, U>>
Short-circuits on Err. std: Result::and_then
Sourcepub fn catch<Params, S: IntoStep<&'static Err, (), Params>>(
self,
f: S,
registry: &Registry,
) -> DagChain<E, Option<T>, DagCatchNode<Chain, S::Step>>
pub fn catch<Params, S: IntoStep<&'static Err, (), Params>>( self, f: S, registry: &Registry, ) -> DagChain<E, Option<T>, DagCatchNode<Chain, S::Step>>
Handle error and transition to Option.
Sourcepub fn map_err<Err2, Params, S: IntoStep<Err, Err2, Params>>(
self,
f: S,
registry: &Registry,
) -> DagChain<E, Result<T, Err2>, MapErrNode<Chain, S::Step>>
pub fn map_err<Err2, Params, S: IntoStep<Err, Err2, Params>>( self, f: S, registry: &Registry, ) -> DagChain<E, Result<T, Err2>, MapErrNode<Chain, S::Step>>
Transform the error. std: Result::map_err
Sourcepub fn or_else<Err2, Params, S: IntoStep<Err, Result<T, Err2>, Params>>(
self,
f: S,
registry: &Registry,
) -> DagChain<E, Result<T, Err2>, OrElseNode<Chain, S::Step>>
pub fn or_else<Err2, Params, S: IntoStep<Err, Result<T, Err2>, Params>>( self, f: S, registry: &Registry, ) -> DagChain<E, Result<T, Err2>, OrElseNode<Chain, S::Step>>
Recover from Err. std: Result::or_else
Sourcepub fn inspect<Params, S: IntoRefStep<T, (), Params>>(
self,
f: S,
registry: &Registry,
) -> DagChain<E, Result<T, Err>, InspectResultNode<Chain, S::Step>>
pub fn inspect<Params, S: IntoRefStep<T, (), Params>>( self, f: S, registry: &Registry, ) -> DagChain<E, Result<T, Err>, InspectResultNode<Chain, S::Step>>
Side effect on Ok. std: Result::inspect
Sourcepub fn inspect_err<Params, S: IntoRefStep<Err, (), Params>>(
self,
f: S,
registry: &Registry,
) -> DagChain<E, Result<T, Err>, InspectErrNode<Chain, S::Step>>
pub fn inspect_err<Params, S: IntoRefStep<Err, (), Params>>( self, f: S, registry: &Registry, ) -> DagChain<E, Result<T, Err>, InspectErrNode<Chain, S::Step>>
Side effect on Err. std: Result::inspect_err
Sourcepub fn ok(self) -> DagChain<E, Option<T>, OkResultNode<Chain>>
pub fn ok(self) -> DagChain<E, Option<T>, OkResultNode<Chain>>
Discard error, enter Option land. std: Result::ok
Source§impl<E, T0: 'static, T1: 'static, T2: 'static, Chain> DagChain<E, (T0, T1, T2), Chain>
impl<E, T0: 'static, T1: 'static, T2: 'static, Chain> DagChain<E, (T0, T1, T2), Chain>
Source§impl<E, T0: 'static, T1: 'static, T2: 'static, T3: 'static, Chain> DagChain<E, (T0, T1, T2, T3), Chain>
impl<E, T0: 'static, T1: 'static, T2: 'static, T3: 'static, Chain> DagChain<E, (T0, T1, T2, T3), Chain>
Source§impl<E, T0: 'static, T1: 'static, T2: 'static, T3: 'static, T4: 'static, Chain> DagChain<E, (T0, T1, T2, T3, T4), Chain>
impl<E, T0: 'static, T1: 'static, T2: 'static, T3: 'static, T4: 'static, Chain> DagChain<E, (T0, T1, T2, T3, T4), Chain>
Source§impl<E, Out: PipelineOutput, Chain: ChainCall<E, Out = Out>> DagChain<E, Out, Chain>
impl<E, Out: PipelineOutput, Chain: ChainCall<E, Out = Out>> DagChain<E, Out, Chain>
Sourcepub fn build_batch(self, capacity: usize) -> BatchDag<E, Chain>
pub fn build_batch(self, capacity: usize) -> BatchDag<E, Chain>
Finalize into a BatchDag with a pre-allocated input buffer.
Same DAG chain as build, but the DAG owns an
input buffer that drivers fill between dispatch cycles. Each call
to BatchDag::run drains the buffer, running every item through
the chain independently.
Available when the DAG ends with () or Option<()> (e.g.
after .guard() or .filter() followed by .unwrap_or(())).
capacity is the initial allocation — the buffer can grow if needed,
but sizing it for the expected batch size avoids reallocation.