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

  1. Empty matchers fast-path: return frame unchanged
  2. rayon par_iter().find_map_first() for parallel first-match-wins semantics
  3. Finder::find() checks if header name pattern exists in the line
  4. memchr::memchr(b’:’) finds the colon separator
  5. If both match: reconstruct as [name, b”: ”, value].concat() into Bytes
  6. find_map_first guarantees first matcher in Vec wins even under parallel execution
  7. 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