pipeline_derive
A procedural macro crate providing a #[derive(Pipeline)] macro to build monadic-style pipelines over Option<T> fields.
Overview
This crate enables you to wrap a single Option<T> field in a struct and automatically generate convenient pipeline methods that chain multiple processing steps. Each step is a closure consuming the value and returning Option<T>, allowing early termination on failure (None), embodying Rust’s monadic pattern with Option.
New attributes let you customise behaviour:
#[pipeline(skip = true)]— generate pipeline methods that always returnNone, effectively skipping processing.#[pipeline(timeout = <milliseconds>)]— pipeline methods print timeout info when called.
Generated pipeline methods now take &self and internally clone the inner value as needed, so the original struct can be used without transferring ownership. The macro automatically adds the required T: Clone trait bound on the generic type.
Features
- Automatically generate pipeline methods (
process3,process4) for 2 or 3-step pipelines. - Pipeline steps are closures
FnOnce(T) -> Option<T>. - Pipeline chains steps with short-circuiting via
Option::and_then. - Attributes to skip processing or log timeout info.
- Methods take
&selfand clone inner value, improving ergonomics. - Minimal, monadic-style API.
Usage Example
use Pipeline;