1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! The [`Decoder`] trait: converting raw bytes into typed messages.
//!
//! A decoder sits between a [`crate::Source`] and the rest of the pipeline.
//! It is the only place in a pipeline where supplier-specific wire-format
//! knowledge lives. Everything downstream operates on the decoded
//! `Output` type and never inspects raw bytes again.
//!
//! ## Pairing with a source
//!
//! A decoder is always paired with its source at builder / configuration
//! time. The pairing is enforced by the type system: `Decoder::Output`
//! must match the message type `M` expected by every downstream stage
//! (`PreProcessor<Message = M>`, `Placement<Message = M>`,
//! `Sink<Message = M>`).
//!
//! ## Input assumption
//!
//! `decode` receives one complete framed record. Framing (splitting a
//! byte stream into records) is the source / framer's responsibility.
//!
//! ## Filtering
//!
//! Returning `Ok(None)` drops a frame (malformed, filtered, or control).
//! Returning `Err` signals a genuine decode failure.
use ;
/// Converts a raw byte slice produced by a [`crate::Source`] into a
/// typed [`Message`].
///
/// Decoders that live on a worker thread must be `Send + Sync`.