| Crates.io | pipeline_derive |
| lib.rs | pipeline_derive |
| version | 0.1.1 |
| created_at | 2025-08-15 17:37:20.304357+00 |
| updated_at | 2025-08-16 17:44:33.213969+00 |
| description | A procedural macro crate to simplify building monadic-like data pipelines in Rust. |
| homepage | https://github.com/ParkBlake/pipeline_derive |
| repository | https://github.com/ParkBlake/pipeline_derive |
| max_upload_size | |
| id | 1797163 |
| size | 23,434 |
A procedural macro crate providing a #[derive(Pipeline)] macro to build monadic-style pipelines over Option<T> fields.
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 return None, 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.
process3, process4) for 2 or 3-step pipelines.FnOnce(T) -> Option<T>.Option::and_then.&self and clone inner value, improving ergonomics.use pipeline_derive::Pipeline;
#[derive(Pipeline)]
#[pipeline(timeout = 1000)]
struct MyPipeline<T> {
value: Option<T>,
}
fn main() {
let pipeline = MyPipeline { value: Some(7) };
let result = pipeline.process3(
|x| Some(x + 3),
|y| if y > 10 { Some(y * 2) } else { None },
);
match result {
Some(output) => println!("Pipeline succeeded with output: {}", output),
None => println!("Pipeline terminated early."),
}
}