pub struct Pipeline<S>where
S: Source,{ /* private fields */ }Expand description
A built pipeline. Run with Pipeline::run (sync) or
Pipeline::run_threaded (std).
Implementations§
Source§impl<S> Pipeline<S>
impl<S> Pipeline<S>
Sourcepub fn from_source(
source: S,
) -> PipelineBuilder<S::Item, S, impl FnOnce(Box<dyn FnMut(StageOp<S::Item>) -> Result<()> + Send + 'static>) -> Box<dyn FnMut(StageOp<S::Item>) -> Result<()> + Send + 'static> + Send + 'static>
pub fn from_source( source: S, ) -> PipelineBuilder<S::Item, S, impl FnOnce(Box<dyn FnMut(StageOp<S::Item>) -> Result<()> + Send + 'static>) -> Box<dyn FnMut(StageOp<S::Item>) -> Result<()> + Send + 'static> + Send + 'static>
Start a new pipeline from a Source.
Sourcepub fn run(self) -> Result<RunStats>
pub fn run(self) -> Result<RunStats>
Run the pipeline to completion on the calling thread.
§Errors
Returns the first error produced by the source, any stage, or the sink.
Sourcepub fn run_with<D>(self, driver: D) -> Result<RunStats>
pub fn run_with<D>(self, driver: D) -> Result<RunStats>
Run the pipeline with an explicit crate::driver::Driver.
Use this for built-in drivers when you want to be explicit
(pipeline.run_with(ThreadedDriver::new())) or for custom
executors (your own crate::driver::Driver impl).
The crate::driver::Driver trait carries Send bounds on
the source and its item/error types; if your pipeline cannot
satisfy Send, call crate::driver::SyncDriver::run
directly instead (its inherent method has looser bounds).
§Errors
Returns the first error produced by the source, any stage, or the sink.
Sourcepub fn run_threaded(self) -> Result<RunStats>
Available on crate feature std only.
pub fn run_threaded(self) -> Result<RunStats>
std only.Run the pipeline to completion on a spawned thread.
§Errors
Returns the first error produced by the source, any stage, or
the sink. Returns Error::Cancelled if the worker thread
panics.
Source§impl Pipeline<IterSource<Empty<()>>>
impl Pipeline<IterSource<Empty<()>>>
Sourcepub fn from_iter<II>(
iter: II,
) -> PipelineBuilder<II::Item, IterSource<II::IntoIter>, impl FnOnce(Box<dyn FnMut(StageOp<II::Item>) -> Result<()> + Send + 'static>) -> Box<dyn FnMut(StageOp<II::Item>) -> Result<()> + Send + 'static> + Send + 'static>
pub fn from_iter<II>( iter: II, ) -> PipelineBuilder<II::Item, IterSource<II::IntoIter>, impl FnOnce(Box<dyn FnMut(StageOp<II::Item>) -> Result<()> + Send + 'static>) -> Box<dyn FnMut(StageOp<II::Item>) -> Result<()> + Send + 'static> + Send + 'static>
Start a new pipeline from any IntoIterator.
§Example
use pipe_io::{Pipeline, sink::VecSink};
let sink = VecSink::<i32>::new();
let handle = sink.handle();
Pipeline::from_iter(0..3).sink(sink).run().unwrap();
assert_eq!(handle.take(), vec![0, 1, 2]);