Skip to main content

Driver

Trait Driver 

Source
pub trait Driver {
    // Required method
    fn run<S>(self, pipeline: Pipeline<S>) -> Result<RunStats>
       where S: Source + Send + 'static,
             S::Item: Send + 'static,
             S::Error: Send + 'static;
}
Expand description

Generic executor for built pipelines.

Implement for custom executors (tokio’s runtime, a rayon thread pool, a sharded worker farm, etc.). Built-in implementations are SyncDriver and ThreadedDriver.

The trait requires every part of the pipeline to be Send: the source, its item type, and its error type. This matches ThreadedDriver’s natural bounds and lets a custom executor move a pipeline to another thread without extra constraints. If you need to drive a non-Send source on the calling thread, use SyncDriver::run (the inherent method) directly; that path keeps the looser bound.

§Example

use pipe_io::driver::{Driver, RunStats, SyncDriver};
use pipe_io::{sink::NullSink, Pipeline, Result};

fn run_anything<D: Driver>(driver: D) -> Result<RunStats> {
    let pipeline = Pipeline::from_iter(0..5).sink(NullSink::<i32>::new());
    driver.run(pipeline)
}

run_anything(SyncDriver::new()).unwrap();

Required Methods§

Source

fn run<S>(self, pipeline: Pipeline<S>) -> Result<RunStats>
where S: Source + Send + 'static, S::Item: Send + 'static, S::Error: Send + 'static,

Drive a pipeline to completion.

§Errors

Returns the first error produced by the source, any stage, or the sink.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Driver for SyncDriver

Source§

impl Driver for ThreadedDriver

Available on crate feature std only.