Skip to main content

FlowExtractor

Trait FlowExtractor 

Source
pub trait FlowExtractor:
    Send
    + Sync
    + 'static {
    type Key: Eq + Hash + Clone + Send + Sync + 'static;

    // Required method
    fn extract(&self, view: PacketView<'_>) -> Option<Extracted<Self::Key>>;
}
Expand description

Extract a flow descriptor from one packet.

Implementations are called once per packet on the hot path — keep them cheap and stateless. Most return Some(_); malformed, non-IP, or out-of-scope packets return None and are skipped.

§Bidirectional flows

If you want A→B and B→A merged into one flow, your extractor must produce the same Key for both orientations and report each packet’s direction via Extracted::orientation. The built-in crate::extract::FiveTuple::bidirectional does this by sorting (addr, port) pairs.

§Bounds

Send + Sync + 'static is required so a tracker generic over this trait can be used from any task / thread.

Required Associated Types§

Source

type Key: Eq + Hash + Clone + Send + Sync + 'static

The flow key. Equality + hashability identify the flow.

Required Methods§

Source

fn extract(&self, view: PacketView<'_>) -> Option<Extracted<Self::Key>>

Extract a flow descriptor from view.

Returns None if this packet is not part of any flow you want to track (skipped, malformed, encap-only, ARP, etc.).

Implementors§

Source§

impl FlowExtractor for FiveTuple

Available on crate feature extractors only.
Source§

impl FlowExtractor for IpPair

Available on crate feature extractors only.
Source§

impl FlowExtractor for MacPair

Available on crate feature extractors only.
Source§

impl<E> FlowExtractor for FlowLabel<E>
where E: FlowExtractor, E::Key: Hash + Eq + Clone + Send + Sync + 'static,

Available on crate feature extractors only.
Source§

impl<E, H> FlowExtractor for DnsUdpObserver<E, H>
where E: FlowExtractor, H: DnsHandler, E::Key: Eq + Hash + Clone,

Available on crate feature dns only.
Source§

impl<E: FlowExtractor + Clone> FlowExtractor for AutoDetectEncap<E>

Available on crate feature extractors only.
Source§

impl<E: FlowExtractor> FlowExtractor for InnerGre<E>

Available on crate feature extractors only.
Source§

impl<E: FlowExtractor> FlowExtractor for InnerGtpU<E>

Available on crate feature extractors only.
Source§

impl<E: FlowExtractor> FlowExtractor for StripMpls<E>

Available on crate feature extractors only.
Source§

impl<E: FlowExtractor> FlowExtractor for StripVlan<E>

Available on crate feature extractors only.
Source§

impl<E: FlowExtractor> FlowExtractor for InnerVxlan<E>

Available on crate feature extractors only.