PacketSource

Trait PacketSource 

Source
pub trait PacketSource:
    Send
    + Sync
    + Clone
    + 'static {
    type Reader: PacketReader;

    // Required methods
    fn metadata(&self) -> &PacketSourceMetadata;
    fn reader(&self, range: Option<&PacketRange>) -> Result<Self::Reader, Error>;

    // Provided methods
    fn partitions(
        &self,
        _max_partitions: usize,
    ) -> Result<Vec<PacketRange>, Error> { ... }
    fn link_type(&self) -> u32 { ... }
}
Expand description

Source of packet data. Creates readers and computes partitions.

This trait uses an associated type for Reader to enable static dispatch in the hot path, matching the enum-dispatch pattern used for protocols.

§Design Notes

We use generics rather than Box<dyn PacketReader> because:

  1. Each QueryEngine uses ONE source type (no heterogeneous mixing)
  2. The hot loop uses reader.process_packets() for zero-copy access
  3. Static dispatch enables inlining and optimization
  4. Type erasure happens at DataFusion boundaries anyway

Required Associated Types§

Source

type Reader: PacketReader

The reader type this source produces

Required Methods§

Source

fn metadata(&self) -> &PacketSourceMetadata

Get metadata about this source

Source

fn reader(&self, range: Option<&PacketRange>) -> Result<Self::Reader, Error>

Create a reader for the given range. If range is None, reads the entire source.

Provided Methods§

Source

fn partitions(&self, _max_partitions: usize) -> Result<Vec<PacketRange>, Error>

Compute partition boundaries for parallel reading.

Returns at most max_partitions non-overlapping ranges that cover the entire source. The default implementation returns a single partition (the whole source).

§Phase 2.5

This default implementation is sufficient for Phase 2. Phase 2.5 will override this to scan the file and find packet boundaries at approximately equal byte offsets.

Get the link type for this source.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§