pub struct ParseResult<'data> {
pub fields: SmallVec<[FieldEntry<'data>; 16]>,
pub remaining: &'data [u8],
pub child_hints: SmallVec<[HintEntry; 4]>,
pub error: Option<String>,
pub encap_depth: u8,
pub tunnel_type: TunnelType,
pub tunnel_id: Option<u64>,
}Expand description
Result of parsing a protocol layer.
Uses SmallVec for inline storage to avoid HashMap allocation overhead. Most protocols have <16 fields and <4 child hints, so these fit inline.
The lifetime parameter 'data ties the result to the packet/buffer data,
allowing zero-copy parsing where field values reference the packet directly.
Fields§
§fields: SmallVec<[FieldEntry<'data>; 16]>Extracted field values. Most protocols have <16 fields. Field values may reference the packet data (zero-copy).
remaining: &'data [u8]Remaining unparsed bytes (payload for next layer).
child_hints: SmallVec<[HintEntry; 4]>Hints for child protocol identification. Typically 2-4 entries.
error: Option<String>Parse error if partial parsing occurred.
encap_depth: u8Encapsulation depth when this protocol was parsed (0 = outer layer).
tunnel_type: TunnelTypeType of the innermost enclosing tunnel (if inside a tunnel).
tunnel_id: Option<u64>Identifier of the innermost enclosing tunnel (VNI, GRE key, TEID, etc.).
Implementations§
Source§impl<'data> ParseResult<'data>
impl<'data> ParseResult<'data>
Sourcepub fn success(
fields: SmallVec<[FieldEntry<'data>; 16]>,
remaining: &'data [u8],
child_hints: SmallVec<[HintEntry; 4]>,
) -> Self
pub fn success( fields: SmallVec<[FieldEntry<'data>; 16]>, remaining: &'data [u8], child_hints: SmallVec<[HintEntry; 4]>, ) -> Self
Create a successful parse result.
Note: encap_depth, tunnel_type, and tunnel_id default to 0/None.
These are populated by the parse loop from the ParseContext after parsing.
Sourcepub fn partial(
fields: SmallVec<[FieldEntry<'data>; 16]>,
remaining: &'data [u8],
error: String,
) -> Self
pub fn partial( fields: SmallVec<[FieldEntry<'data>; 16]>, remaining: &'data [u8], error: String, ) -> Self
Create a result with partial fields and an error.
Sourcepub fn set_encap_context(&mut self, ctx: &ParseContext)
pub fn set_encap_context(&mut self, ctx: &ParseContext)
Set encapsulation context from a ParseContext.
Sourcepub fn get(&self, name: &str) -> Option<&FieldValue<'data>>
pub fn get(&self, name: &str) -> Option<&FieldValue<'data>>
Get a field value by name (linear search, but N is small).
Trait Implementations§
Source§impl<'data> Clone for ParseResult<'data>
impl<'data> Clone for ParseResult<'data>
Source§fn clone(&self) -> ParseResult<'data>
fn clone(&self) -> ParseResult<'data>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more