pub struct Builder<Input, Output, Error, Context, NodeTypes = (), NodeIOETypes = ()>{ /* private fields */ }Expand description
Builder for ParallelFlow.
This builder ensures:
Inputinto the flow can be converted into the input of all nodes- error of all nodes can be converted into the
Errorof the flow JoinerreturnsResult<Output, Error>
See also ParallelFlow.
Implementations§
Source§impl<Input, Output, Error, Context> Builder<Input, Output, Error, Context>
impl<Input, Output, Error, Context> Builder<Input, Output, Error, Context>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty builder for ParallelFlow.
Sourcepub fn add_node<NodeType, NodeInput, NodeOutput, NodeError>(
self,
node: NodeType,
) -> Builder<Input, Output, Error, Context, (NodeType,), ((), (NodeInput, NodeOutput<NodeOutput>, NodeError))>
pub fn add_node<NodeType, NodeInput, NodeOutput, NodeError>( self, node: NodeType, ) -> Builder<Input, Output, Error, Context, (NodeType,), ((), (NodeInput, NodeOutput<NodeOutput>, NodeError))>
Source§impl<Input, Output, Error, Context, NodeTypes, OtherNodeIOETypes, LastNodeIOETypes> Builder<Input, Output, Error, Context, NodeTypes, (OtherNodeIOETypes, LastNodeIOETypes)>
impl<Input, Output, Error, Context, NodeTypes, OtherNodeIOETypes, LastNodeIOETypes> Builder<Input, Output, Error, Context, NodeTypes, (OtherNodeIOETypes, LastNodeIOETypes)>
Sourcepub fn add_node<NodeType, NodeInput, NodeOutput, NodeError>(
self,
node: NodeType,
) -> Builder<Input, Output, Error, Context, (NodeTypes, NodeType), ((OtherNodeIOETypes, LastNodeIOETypes), (NodeInput, NodeOutput<NodeOutput>, NodeError))>
pub fn add_node<NodeType, NodeInput, NodeOutput, NodeError>( self, node: NodeType, ) -> Builder<Input, Output, Error, Context, (NodeTypes, NodeType), ((OtherNodeIOETypes, LastNodeIOETypes), (NodeInput, NodeOutput<NodeOutput>, NodeError))>
Sourcepub fn build<J, ChainRunOutput>(
self,
joiner: J,
) -> Flow<Input, Output, Error, Context, ChainRunOutput, J, NodeTypes, (OtherNodeIOETypes, LastNodeIOETypes)>where
for<'a> J: Joiner<'a, ChainRunOutput, Output, Error, Context>,
NodeTypes: ChainRun<Input, Result<ChainRunOutput, Error>, Context, (OtherNodeIOETypes, LastNodeIOETypes)>,
pub fn build<J, ChainRunOutput>(
self,
joiner: J,
) -> Flow<Input, Output, Error, Context, ChainRunOutput, J, NodeTypes, (OtherNodeIOETypes, LastNodeIOETypes)>where
for<'a> J: Joiner<'a, ChainRunOutput, Output, Error, Context>,
NodeTypes: ChainRun<Input, Result<ChainRunOutput, Error>, Context, (OtherNodeIOETypes, LastNodeIOETypes)>,
Finalizes the builder and produces a ParallelFlow instance.
The joiner must satisfy:
Self:Joiner<'_, NodesOutputs, Output, Error, _>
When using closure as a joiner it always needs:
- to be an async closure - because of lifetimes
- for context to:
- have the type of a context specified when using context - because it cannot infer the type
or - have the context specified as
_: &mut _when not using context - because it cannot satisfy thatJoineris implemented
- have the type of a context specified when using context - because it cannot infer the type
§Examples
// ...
.build(async |_, _: &mut _| {
Ok(NodeOutput::Ok(120))
});
// ...
.build(async |_, ctx: &mut Context| {
let _forked_ctx = ctx.fork();
Ok(NodeOutput::Ok(120))
});Trait Implementations§
Auto Trait Implementations§
impl<Input, Output, Error, Context, NodeTypes, NodeIOETypes> Freeze for Builder<Input, Output, Error, Context, NodeTypes, NodeIOETypes>where
NodeTypes: Freeze,
impl<Input, Output, Error, Context, NodeTypes, NodeIOETypes> RefUnwindSafe for Builder<Input, Output, Error, Context, NodeTypes, NodeIOETypes>where
NodeTypes: RefUnwindSafe,
impl<Input, Output, Error, Context, NodeTypes, NodeIOETypes> Send for Builder<Input, Output, Error, Context, NodeTypes, NodeIOETypes>where
NodeTypes: Send,
impl<Input, Output, Error, Context, NodeTypes, NodeIOETypes> Sync for Builder<Input, Output, Error, Context, NodeTypes, NodeIOETypes>where
NodeTypes: Sync,
impl<Input, Output, Error, Context, NodeTypes, NodeIOETypes> Unpin for Builder<Input, Output, Error, Context, NodeTypes, NodeIOETypes>where
NodeTypes: Unpin,
impl<Input, Output, Error, Context, NodeTypes, NodeIOETypes> UnwindSafe for Builder<Input, Output, Error, Context, NodeTypes, NodeIOETypes>where
NodeTypes: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more