Skip to main content

Tuple

Trait Tuple 

Source
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§

Source

fn from_packet(pkt: &Packet<'_>, vni_mapper: &mut VniMapper) -> Option<Self>

Create a new flow tuple from a packet

Source

fn flip(&self) -> Self

Flip the source and destination fields of the flow tuple

Source

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).

Source

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).

Source

fn source(&self) -> Self::Addr

Returns the source address of the flow tuple.

Source

fn dest(&self) -> Self::Addr

Returns the destination address of the flow tuple.

Source

fn source_port(&self) -> u16

Returns the source port of the flow tuple.

Source

fn dest_port(&self) -> u16

Returns the destination port of the flow tuple.

Source

fn protocol(&self) -> IpProto

Returns the IP protocol of the flow tuple.

Source

fn vni(&self) -> VniId

Returns the VNI (VXLAN Network Identifier) of the flow tuple.

Provided Methods§

Source

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.

Implementors§