Skip to main content

packet_strata/tracker/
process.rs

1use crate::{
2    metadata::PacketMetadata,
3    packet::Packet,
4    tracker::{direction::PacketDirection, flow::FlowBase},
5};
6
7/// A trait for types that can process a packet and update their state.
8///
9/// This is primarily used by `Flow` to update statistics (counters, timestamps)
10/// and protocol-specific state machines (like TCP) upon receiving a new packet.
11pub trait Process {
12    /// Update the state based on the provided packet metadata and content.
13    ///
14    /// # Arguments
15    ///
16    /// * `meta` - Packet metadata (timestamp, length, etc.)
17    /// * `pkt` - The parsed packet
18    /// * `dir` - Direction of the packet relative to the flow
19    /// * `core` - Mutable reference to the flow's core statistics and metadata
20    fn process<Meta: PacketMetadata, T>(
21        &mut self,
22        meta: &Meta,
23        pkt: &Packet<'_>,
24        dir: PacketDirection,
25        base: &mut FlowBase<T>,
26    );
27}
28
29impl Process for () {
30    #[inline(always)]
31    fn process<Meta: PacketMetadata, T>(
32        &mut self,
33        _meta: &Meta,
34        _pkt: &Packet<'_>,
35        _dir: PacketDirection,
36        _base: &mut FlowBase<T>,
37    ) {
38    }
39}