Struct async_pipes::PipelineBuilder
source · pub struct PipelineBuilder { /* private fields */ }Expand description
Used to construct a Pipeline.
Can be created using Pipeline::builder.
Implementations§
source§impl PipelineBuilder
impl PipelineBuilder
sourcepub fn with_inputs<S, I>(self, pipe: S, inputs: Vec<I>) -> Self
pub fn with_inputs<S, I>(self, pipe: S, inputs: Vec<I>) -> Self
A “producer” stage; registers a list of inputs to be written to a provided pipe.
The string provided to pipe defines where the values will be written to.
The values will be written one at a time into the pipe.
Returns
This pipeline builder.
sourcepub fn with_branching_inputs<S>(
self,
pipes: Vec<S>,
inputs: Vec<Vec<BoxedAnySend>>
) -> Self
pub fn with_branching_inputs<S>( self, pipes: Vec<S>, inputs: Vec<Vec<BoxedAnySend>> ) -> Self
A “producer” stage; registers a list of multiple inputs to be written to a list of corresponding pipes.
The strings provided to pipes define where each input will go.
The values will be written one at a time into each pipe.
For example, say you have the following:
List of multiple inputs: [ [1, "hi", true], [2, "bye", false], [3, ".", false] ]
List of pipes: [ "numbers", "strings", "bools" ]
The inputs would be sent to the pipes like this:
Pipe 1st 2nd 3rd
"numbers" <- 1 2 3
"strings" <- "hi" "bye" "."
"bools" <- true false false
Returns
This pipeline builder.
sourcepub fn with_producer<S, I, F, Fut>(self, pipe: S, task: F) -> Self
pub fn with_producer<S, I, F, Fut>(self, pipe: S, task: F) -> Self
A “producer” stage; registers a stage that produces values and writes them into a pipe.
The strings provided to pipes define where each input will go.
The producer will continue producing values while the user-provided task function returns Some. This means that it is possible to create an infinite stream of values by simply never returning None.
Returns
This pipeline builder.
sourcepub fn with_branching_producer<S, F, Fut>(self, pipes: Vec<S>, task: F) -> Self
pub fn with_branching_producer<S, F, Fut>(self, pipes: Vec<S>, task: F) -> Self
A “producer” stage; registers a new stage that produces multiple values and writes them into their respective pipe.
The strings provided to pipes define where each input will go.
The producer will continue producing values while the user-provided task function returns Some. This means that it is possible to create an infinite stream of values by simply never returning None.
Each individual Option within the task output determines whether it will be sent to the corresponding pipe. If Some is specified, the inner value will be sent, if None is specified, nothing will be sent.
As with all stages that have more than one (“branching”) outputs, it’s possible that each output could have a different type, and so to avoid large binary sizes from static dispatching, dynamic dispatching is used instead, utilizing the BoxedAnySend type. For examples on how to return these types of values in task functions, see BoxedAnySend’s examples.
Returns
This pipeline builder.
sourcepub fn with_consumer<S, I, F, Fut>(self, pipe: S, task: F) -> Self
pub fn with_consumer<S, I, F, Fut>(self, pipe: S, task: F) -> Self
A “consumer” stage; registers a new stage that consumes values from a pipe.
The string provided to pipe define where values will be read from.
The consumer will continue consuming values until the pipeline is terminated or the pipe it is receiving from is closed.
Returns
This pipeline builder.
sourcepub fn with_stage<S, I, O, F, Fut>(
self,
input_pipe: S,
output_pipe: S,
task: F
) -> Self
pub fn with_stage<S, I, O, F, Fut>( self, input_pipe: S, output_pipe: S, task: F ) -> Self
A “regular” stage; registers a new stage that operates on an input and produce a single output value that is written to a pipe.
The string provided to input_pipe defines where values will be read from.
The string provided to output_pipe defines where the produced output will go.
The worker will continue working on input values until the pipeline is terminated or the pipe it is receiving from is closed.
The Option returned by the task function determines whether it will be sent to the output pipe. If Some is specified, the inner value will be sent, if None is specified, nothing will be sent.
Returns
This pipeline builder.
sourcepub fn with_branching_stage<S, I, F, Fut>(
self,
input_pipe: S,
output_pipes: Vec<S>,
task: F
) -> Self
pub fn with_branching_stage<S, I, F, Fut>( self, input_pipe: S, output_pipes: Vec<S>, task: F ) -> Self
A “regular” stage; registers a new stage that operates on an input and produces multiple values that are written into their respective pipe.
The string provided to input_pipe defines where values will be read from.
The strings provided to output_pipes define where each produced output will go.
The worker will continue working on input values until the pipeline is terminated or the pipe it is receiving from is closed.
- If the user-defined task function returns None, nothing will be done.
- If it returns Some, the inner value (Vec<Option
> ) will have the following applied to each output option:
As with all stages that have more than one (“branching”) outputs, it’s possible that each output could have a different type, and so to avoid large binary sizes from static dispatching, dynamic dispatching is used instead, utilizing the BoxedAnySend type. For examples on how to return these types of values in task functions, see BoxedAnySend’s examples.
Returns
This pipeline builder.
sourcepub fn build(self) -> Result<Pipeline, String>
pub fn build(self) -> Result<Pipeline, String>
When the pipeline is ready to be built, this is called and will return a pipeline if it was successfully built, otherwise it will return an error describing why it could not be built.
Errors
- A pipe was specified as an “output” pipe for a stage and it doesn’t exist
- The reader of a pipe was used more than once