Skip to main content

Module driver

Module driver 

Source
Available on crate features extractors and reassembler and session only.
Expand description

flowscope::driver — the typed Driver<E> + SlotHandle<M, K> shape (plan 121).

use flowscope::driver::{Driver, Event, SlotMessage};
use flowscope::extract::{FiveTuple, FiveTupleKey};
use flowscope::http::{HttpMessage, HttpParser};

let mut builder = Driver::builder(FiveTuple::bidirectional());
let mut http_slot = builder.session_on_ports(HttpParser::default(), [80, 8080]);
let mut driver = builder.build();

let mut events: Vec<Event<FiveTupleKey>> = Vec::new();
let mut http_msgs: Vec<SlotMessage<HttpMessage, FiveTupleKey>> = Vec::new();

// driver.track_into(view, &mut events);
// http_slot.drain(&mut http_msgs);

§Architecture

  • Driver<E> owns a central crate::FlowTracker for flow lifecycle + per-parser slots that own their inner session/datagram drivers.
  • Each .session_* / .datagram_* builder call returns a typed SlotHandle<M, K>; the slot’s typed messages flow into the handle’s internal buffer via a shared Arc<crossbeam_queue::SegQueue<_>>.
  • Per-packet: driver.track_into(view, &mut events) emits flow-lifecycle events; slot.drain(&mut msgs) drains the typed messages produced this packet.
  • Zero-allocation in steady state across the full dispatch path including registered slots.

Plan 122 (0.12): SlotHandle<M, K> is Send + Sync (backed by Arc<crossbeam_queue::SegQueue>). Move the handle to a worker thread, share via Arc with multiple drainers, drain from a tokio task on another core.

Plan 156 (0.13): the driver itself (Driver<E>) is also Send + Sync. The 0.12 docs claimed otherwise on the basis that FlowTracker used Rc<RefCell> interior mutability; this was never true — the actual !Send source was a missing + Send bound on the Box<dyn ErasedSlot<_>> slot list. Tightening that bound (no unsafe, no opt-in knob) makes the whole driver Send+Sync. The 0.13 typical pattern is tokio::spawn(driver_task) on the default multi-thread runtime.

Structs§

BroadcastSlotHandle
Per-subscriber broadcast handle. Each Clone yields a new subscriber with its own private queue; every push to the owning slot fans out to every live subscriber.
Driver
Plan 121 typed driver. Emits flow-lifecycle Event<K> only; per-parser typed messages flow through SlotHandle.
DriverBuilder
Builder for Driver. Mutates in place; each session/datagram registration returns a typed SlotHandle.
SlotHandle
Typed drain handle returned by the builder for each registered parser. The slot pushes and the handle drains — both share the same Arc<SegQueue>.
SlotMessage
One typed message emitted by a registered parser.

Enums§

Event
Flow-lifecycle event type for the typed driver.

Constants§

DEFAULT_PROBE_PACKETS
Default probing-budget if the user doesn’t override.
PROBE_BUFFER_CAP
Buffer cap per side during the probing phase. Every shipped signature decides within ≤ 64 B.

Traits§

SlotDrain
Shared drain surface across SlotHandle (competitive-consumer, MPMC) and super::BroadcastSlotHandle (fan-out). Lets a downstream drain loop stay generic over which delivery mode a slot was registered with — e.g. fn pump(s: &mut impl SlotDrain<M, K>).