Skip to main content

Event

Enum Event 

Source
#[non_exhaustive]
pub enum Event<K> { Started { key: K, orientation: Orientation, ts: Timestamp, l4: Option<L4Proto>, }, Established { key: K, ts: Timestamp, l4: Option<L4Proto>, }, StateChange { key: K, from: FlowState, to: FlowState, ts: Timestamp, },
#[non_exhaustive]
Packet { key: K, side: FlowSide, orientation: Orientation, len: usize, ts: Timestamp, tcp: Option<TcpInfo>, source_idx: Option<u32>, }, Ended { key: K, reason: EndReason, stats: FlowStats, history: HistoryString, l4: Option<L4Proto>, ts: Timestamp, }, Tick { key: K, stats: FlowStats, ts: Timestamp, }, ParserClosed { key: K, parser_kind: ParserKind, reason: EndReason, ts: Timestamp, }, FlowAnomaly { key: K, kind: AnomalyKind, ts: Timestamp, }, TrackerAnomaly { kind: AnomalyKind, ts: Timestamp, }, }
Available on crate features extractors and reassembler and session only.
Expand description

Flow-lifecycle event type for the typed driver.

Plan 121: no M parameter, no Message variant — per-parser typed messages flow through SlotHandle returned by the builder. ParserClosed stays as a lifecycle marker for when a parser self-terminates.

Serializeable under the serde feature with the same tag = "type" / snake_case shape as FlowEvent, and convertible from it via Event::from(flow_event) (issue #97). The conversion is lossless — FlowEvent::StateChange maps to Self::StateChange.

Since 0.20 (#110) the variants share FlowEvent’s names (no redundant Flow prefix), so the two enums also serialize to the same type tags ("started", "established", "ended", …).

Serialize only (not Deserialize): the driver only ever emits events, so only the serialize half is derived. To read events back, deserialize the tracker primitive FlowEvent (which is round-trippable) and Event::from it.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Started

First packet of a new flow.

orientation is the flow’s deterministic canonical direction (Orientation, issue #118) — equal to the initiator’s orientation and to FlowStats::initiator_orientation.

Fields

§key: K
§orientation: Orientation

Canonical (address-sorted) orientation of the flow’s first packet. Deterministic regardless of arrival order.

§

Established

TCP flow reached the Established state (3-way handshake complete). Not emitted for UDP / ICMP flows.

Fields

§key: K
§

StateChange

TCP state-machine transition other than reaching Established (e.g. Established → FinWait). The lossless counterpart of FlowEvent::StateChange (issue #97).

The typed Driver<E> does not emit this today — Established covers the common case and the driver historically omits raw state churn — but the variant exists so Event::from(FlowEvent::StateChange { .. }) is lossless and so future driver modes can surface it.

Fields

§key: K
§

#[non_exhaustive]
Packet

Per-packet event on an existing flow.

§Per-packet TCP details

The tcp field is always None unless the driver was built with DriverBuilder::emit_packet_details(true) — that’s an opt-in, off by default to avoid per-packet extractor re-parse cost. Reading tcp on a default- configured driver and getting None is expected, not a bug. Use the convenience accessor Event::tcp when you want “tcp info if available, on any variant” without destructuring. The variant is #[non_exhaustive] (0.21, issue #121) — future per-packet enrichments are additive. Construct synthetic packets via flowscope::test_helpers::events::driver::packet*; match with a trailing ...

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§key: K
§orientation: Orientation

Canonical (address-sorted) orientation of this packet (Orientation, issue #118). Together with the flow’s FlowStats::initiator_orientation it recovers side deterministically.

§len: usize
§source_idx: Option<u32>

Physical capture leg this packet arrived on (issue #121). Opt-in via DriverBuilder::emit_packet_source_idx — always None otherwise; None also for the 0 “unused” sentinel. See crate::FlowEvent::Packet’s field docs for the audit-tier vs per-direction-binding distinction.

§

Ended

Flow ended (FIN / RST / idle / eviction / parser close).

Fields

§key: K
§reason: EndReason
§

Tick

Periodic FlowStats snapshot — emitted when crate::FlowTrackerConfig::flow_tick_interval is set.

Fields

§key: K
§

ParserClosed

Parser-level close — a registered parser drained its fin_* accumulator or reported is_done / is_poisoned. Distinct from Self::Ended: this fires per (parser, flow); the flow may still be alive.

Fields

§key: K
§parser_kind: ParserKind
§reason: EndReason
§

FlowAnomaly

Live per-flow anomaly forwarded from the central tracker. Emitted only when emit_anomalies(true) was set.

Fields

§key: K
§

TrackerAnomaly

Live tracker-global anomaly.

Fields

Implementations§

Source§

impl<K> Event<K>

Source

pub fn key(&self) -> Option<&K>

Borrow the flow key, if the variant has one.

Source

pub fn tcp(&self) -> Option<&TcpInfo>

Per-packet TCP details, when available.

Returns the tcp field for Self::Packet events; None for every other variant. The field itself is only populated when the driver was built with DriverBuilder::emit_packet_details(true); if you haven’t opted in, this accessor (like the field) always returns None.

Useful for cross-variant pipelines that want “tcp info if the event carries any, otherwise None” without an explicit destructuring match arm on Packet.

Source

pub fn timestamp(&self) -> Timestamp

Borrow the timestamp on the event.

Source

pub fn into_flow_event(self) -> Option<FlowEvent<K>>

Project this typed event back to a tracker FlowEvent, if it has one (issue #97).

Returns None for Self::ParserClosed — a parser-level marker with no tracker-event counterpart. The Self::Packet tcp enrichment is dropped (FlowEvent carries no per-packet TCP details) and Self::Ended’s explicit ts is folded back into stats.last_seen.

This is the bridge that lets the emit writers — which speak FlowEvent — consume a typed Driver<E> stream. See crate::emit for the write_event-over-Event path.

Source

pub fn to_flow_event(&self) -> Option<FlowEvent<K>>
where K: Clone,

Borrowing variant of Self::into_flow_event — clones the key/stats. Convenient for emit writers that take &FlowEvent<K> without consuming the event.

Trait Implementations§

Source§

impl<K: Clone> Clone for Event<K>

Source§

fn clone(&self) -> Event<K>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: Debug> Debug for Event<K>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K> From<FlowEvent<K>> for Event<K>

Source§

fn from(ev: FlowEvent<K>) -> Self

Lossless conversion from the tracker primitive to the typed driver event (issue #97).

Every FlowEvent variant has an Event counterpart: StateChange maps to Event::StateChange, Ended’s timestamp is taken from stats.last_seen, and Event::Packet’s tcp enrichment defaults to None (it is a driver-only, opt-in field — populate it via the driver’s emit_packet_details, not this conversion).

Source§

impl<K: Clone> LifecycleEvent<K> for Event<K>

Available on crate feature emit only.
Source§

fn as_flow_event(&self) -> Option<Cow<'_, FlowEvent<K>>>

Borrow (or produce) this event’s FlowEvent projection, or None if it has none.
Source§

impl<K> Serialize for Event<K>
where K: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<K> Freeze for Event<K>
where K: Freeze,

§

impl<K> RefUnwindSafe for Event<K>
where K: RefUnwindSafe,

§

impl<K> Send for Event<K>
where K: Send,

§

impl<K> Sync for Event<K>
where K: Sync,

§

impl<K> Unpin for Event<K>
where K: Unpin,

§

impl<K> UnsafeUnpin for Event<K>
where K: UnsafeUnpin,

§

impl<K> UnwindSafe for Event<K>
where K: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more