Skip to main content

Driver

Struct Driver 

Source
pub struct Driver<E>
where E: FlowExtractor, E::Key: Hash + Eq + Clone + Send + Sync + 'static,
{ /* private fields */ }
Available on crate features extractors and reassembler and session only.
Expand description

Plan 121 typed driver. Emits flow-lifecycle Event<K> only; per-parser typed messages flow through SlotHandle.

Driver<E> is Send + Sync since 0.13 — every field is structurally Send+Sync (Arc<SegQueue<_>> slot queues, owned FlowDriver, Vec<Box<dyn ErasedSlot<_> + Send + Sync>> slot list). Methods take &mut self, so the Sync impl is decorative — you can borrow the driver across threads, but only one caller mutates at a time. The headline use case is tokio::spawn(driver_task) on the default multi-thread runtime.

Implementations§

Source§

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

Source

pub fn builder(extractor: E) -> DriverBuilder<E>

Begin building.

Source

pub fn track<'v>( &mut self, view: impl Into<PacketView<'v>>, ) -> Vec<Event<E::Key>>

Process one packet. Returns the merged flow-lifecycle event stream. Typed parser messages don’t appear here — drain them via the SlotHandles returned at build time.

Source

pub fn track_into<'v>( &mut self, view: impl Into<PacketView<'v>>, out: &mut Vec<Event<E::Key>>, )

Append-only variant of Self::track. Reuses out’s capacity — zero allocation at the surface in steady state.

Source

pub fn sweep(&mut self, now: Timestamp) -> Vec<Event<E::Key>>

Periodic sweep. Drives idle-timeout Ended events

  • each slot’s on_tick.
Source

pub fn sweep_into(&mut self, now: Timestamp, out: &mut Vec<Event<E::Key>>)

Append-only sweep.

Source

pub fn finish(&mut self) -> Vec<Event<E::Key>>

End-of-input flush.

Source

pub fn finish_into(&mut self, out: &mut Vec<Event<E::Key>>)

Append-only finish.

Source

pub fn run_pcap<P: AsRef<Path>>(self, path: P) -> Result<RunPcap<E>>

Available on crate feature pcap only.

One-call iterator over a pcap file — drives every packet through this driver and yields the lifecycle event stream. Per-parser typed messages still flow through the registered SlotHandles; drain them yourself between iterator pulls if you need them in-line.

This is the multi-parser sibling of the per-protocol *_from_pcap helpers (flowscope::http::requests_from_pcap, flowscope::dns::messages_from_pcap, etc.) — those work when one parser owns the whole walk; this works when you want HTTP + TLS + DNS slots on the same Driver and process the combined event stream in one pass.

use flowscope::driver::Driver;
use flowscope::extract::FiveTuple;
let mut builder = Driver::builder(FiveTuple::bidirectional());
let _http_slot = builder.session_on_ports(HttpParser::default(), [80]);
let driver = builder.build();
for ev in driver.run_pcap("trace.pcap")? {
    let _ev = ev?;
}

Issue #64 (0.18).

Source

pub fn force_close( &mut self, key: &E::Key, now: Timestamp, ) -> Vec<Event<E::Key>>

Force-end the flow with this key. Mirror of crate::FlowTracker::force_close / crate::FlowDriver::force_close at the typed-driver layer.

Drains any reassembler-buffered bytes through each registered slot’s parser (one last feed_* + fin_* per side); typed messages flushed by the parser land in their slot handle, Event::ParserClosed events land in out, and a final Event::Ended with reason crate::EndReason::ForceClosed is emitted by the central tracker.

No-op if key is not currently tracked.

Source

pub fn force_close_into( &mut self, key: &E::Key, now: Timestamp, out: &mut Vec<Event<E::Key>>, )

Append-only variant of Self::force_close. Reuses out’s capacity.

Source

pub fn tracker(&self) -> &FlowTracker<E, ()>

Borrow the underlying tracker for introspection.

Source

pub fn tracker_mut(&mut self) -> &mut FlowTracker<E, ()>

Mutable borrow of the underlying tracker.

Auto Trait Implementations§

§

impl<E> !RefUnwindSafe for Driver<E>

§

impl<E> !UnwindSafe for Driver<E>

§

impl<E> Freeze for Driver<E>
where <E as FlowExtractor>::Key: Sized + Freeze, E: Freeze,

§

impl<E> Send for Driver<E>
where <E as FlowExtractor>::Key: Sized,

§

impl<E> Sync for Driver<E>
where <E as FlowExtractor>::Key: Sized,

§

impl<E> Unpin for Driver<E>
where <E as FlowExtractor>::Key: Sized + Unpin, E: Unpin,

§

impl<E> UnsafeUnpin for Driver<E>

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> 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, 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