pub trait Tuple:
Sized
+ Hash
+ Eq
+ Clone
+ Copy {
type Addr: Eq;
// Required methods
fn from_packet(pkt: &Packet<'_>, vni_mapper: &mut VniMapper) -> Option<Self>;
fn flip(&self) -> Self;
fn hash_canonical<H: Hasher>(&self, state: &mut H);
fn eq_canonical(&self, other: &Self) -> bool;
fn source(&self) -> Self::Addr;
fn dest(&self) -> Self::Addr;
fn source_port(&self) -> u16;
fn dest_port(&self) -> u16;
fn protocol(&self) -> IpProto;
fn vni(&self) -> VniId;
// Provided method
fn is_symmetric(&self) -> bool { ... }
}Expand description
Common trait for all flow tuple types
This trait defines the interface for creating flow tuples from packets. (e.g., 5-tuple with VNI, 3-tuple, MAC-based, etc.)
Required Associated Types§
Required Methods§
Sourcefn from_packet(pkt: &Packet<'_>, vni_mapper: &mut VniMapper) -> Option<Self>
fn from_packet(pkt: &Packet<'_>, vni_mapper: &mut VniMapper) -> Option<Self>
Create a new flow tuple from a packet
Sourcefn hash_canonical<H: Hasher>(&self, state: &mut H)
fn hash_canonical<H: Hasher>(&self, state: &mut H)
Hashes the tuple in a canonical (symmetric) way without creating a new instance.
Used by Symmetric wrapper to ensure Hash(A->B) == Hash(B->A).
Sourcefn eq_canonical(&self, other: &Self) -> bool
fn eq_canonical(&self, other: &Self) -> bool
Checks equality in a canonical (symmetric) way without creating a new instance.
Used by Symmetric wrapper to ensure Eq(A->B, B->A).
Sourcefn source_port(&self) -> u16
fn source_port(&self) -> u16
Returns the source port of the flow tuple.
Provided Methods§
Sourcefn is_symmetric(&self) -> bool
fn is_symmetric(&self) -> bool
Checks if the tuple is symmetric (source equals destination).
A tuple is considered symmetric when both the source address equals the destination address and the source port equals the destination port. This is useful for identifying self-referential connections.
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.