extern crate transformation_pipeline; use transformation_pipeline::{TransformationStage, StageActions, StageResult, TransformationPipeline}; struct FirstTransformation {} impl TransformationStage for FirstTransformation { fn run(&self, _previous: String) -> StageResult { Ok(StageActions::Next("a".to_owned())) } } struct SecondTransformation {} impl TransformationStage for SecondTransformation { fn run(&self, _previous: String) -> StageResult { Ok(StageActions::Skip) } } struct ThirdTransformation {} impl TransformationStage for ThirdTransformation { fn run(&self, previous: String) -> StageResult { assert_eq!(previous, "a".to_owned()); Ok(StageActions::Next("b".to_owned())) } } #[test] fn run_pipeline() { let pipeline: TransformationPipeline = TransformationPipeline::new(vec![ Box::new(FirstTransformation {}), Box::new(SecondTransformation {}), Box::new(ThirdTransformation {}), ]); assert_eq!(pipeline.run("z".to_owned()).unwrap(), "b".to_owned()); }