pcapsql_core/stream/parser.rs
1use crate::schema::FieldDescriptor;
2
3use super::{StreamContext, StreamParseResult};
4
5/// Trait for parsing application protocols from reassembled streams.
6pub trait StreamParser: Send + Sync {
7 /// Protocol identifier (e.g., "http", "tls").
8 fn name(&self) -> &'static str;
9
10 /// Human-readable name.
11 fn display_name(&self) -> &'static str {
12 self.name()
13 }
14
15 /// Check if this parser can handle the stream based on context.
16 fn can_parse_stream(&self, context: &StreamContext) -> bool;
17
18 /// Parse from reassembled stream bytes.
19 ///
20 /// Called repeatedly as more data becomes available.
21 /// Parser should be stateless - all state is managed externally.
22 fn parse_stream(&self, data: &[u8], context: &StreamContext) -> StreamParseResult;
23
24 /// Schema for messages produced by this parser.
25 fn message_schema(&self) -> Vec<FieldDescriptor>;
26}