Task 12 - HttpPipeline
Completed.
What Was Implemented
HttpPipeline in locomotive/src/pipeline.rs — implements FramePipeline for HttpFrame.
Architecture
- matchers field: Vec of (Finder static, Bytes) pairs
- HttpPipeline::new(matchers) constructor
- Implements FramePipeline trait from train_track
process() Logic
- Empty matchers fast-path: return frame unchanged
- rayon par_iter().find_map_first() for parallel first-match-wins semantics
- Finder::find() checks if header name pattern exists in the line
- memchr::memchr(b’:’) finds the colon separator
- If both match: reconstruct as [name, b”: ”, value].concat() into Bytes
- find_map_first guarantees first matcher in Vec wins even under parallel execution
- No match returns original frame unchanged
Key Details
- Finder with static lifetime required for thread safety with rayon
- HttpPipeline is Send + Sync (required by FramePipeline trait bound)
- Exported from locomotive/src/lib.rs
Tests (4 passing)
- first_match_wins
- no_match_passes_through
- empty_matchers_passes_through
- pipeline_is_sync (compile-time bound check)
Files
- Created: locomotive/src/pipeline.rs
- Modified: locomotive/src/lib.rs
- Created: locomotive/tests/pipeline_test.rs