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:
- Each QueryEngine uses ONE source type (no heterogeneous mixing)
- The hot loop uses
reader.process_packets()for zero-copy access - Static dispatch enables inlining and optimization
- Type erasure happens at DataFusion boundaries anyway
Required Associated Types§
Sourcetype Reader: PacketReader
type Reader: PacketReader
The reader type this source produces
Required Methods§
Sourcefn metadata(&self) -> &PacketSourceMetadata
fn metadata(&self) -> &PacketSourceMetadata
Get metadata about this source
Provided Methods§
Sourcefn partitions(&self, _max_partitions: usize) -> Result<Vec<PacketRange>, Error>
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.
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.