Skip to main content

Pipeline

Struct Pipeline 

Source
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>
where S: Source + 'static, S::Item: Send + 'static, S::Error: Send + 'static,

Source

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.

Source

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.

Source

pub fn run_with<D>(self, driver: D) -> Result<RunStats>
where D: Driver, S: Send, S::Item: Send, S::Error: Send,

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.

Source

pub fn run_threaded(self) -> Result<RunStats>
where S: Send, S::Item: Send, S::Error: Send,

Available on crate feature 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<()>>>

Source

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>
where II: IntoIterator, II::Item: Send + 'static, II::IntoIter: 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]);

Auto Trait Implementations§

§

impl<S> Freeze for Pipeline<S>
where S: Freeze,

§

impl<S> !RefUnwindSafe for Pipeline<S>

§

impl<S> Send for Pipeline<S>
where S: Send,

§

impl<S> !Sync for Pipeline<S>

§

impl<S> Unpin for Pipeline<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for Pipeline<S>
where S: UnsafeUnpin,

§

impl<S> !UnwindSafe for Pipeline<S>

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.