pub struct FlowKey {
pub src_ip: IpAddr,
pub dst_ip: IpAddr,
pub src_port: u16,
pub dst_port: u16,
pub protocol: u8,
}Expand description
A 5-tuple that uniquely identifies a network flow.
Fields§
§src_ip: IpAddr§dst_ip: IpAddr§src_port: u16§dst_port: u16§protocol: u8IP protocol number (6 = TCP, 17 = UDP, 1 = ICMP, …).
Implementations§
Source§impl FlowKey
impl FlowKey
Sourcepub fn new(
src_ip: IpAddr,
dst_ip: IpAddr,
src_port: u16,
dst_port: u16,
protocol: u8,
) -> Self
pub fn new( src_ip: IpAddr, dst_ip: IpAddr, src_port: u16, dst_port: u16, protocol: u8, ) -> Self
Create a new flow key, normalising IPv4-mapped IPv6 addresses to IPv4.
Sourcepub fn flow_id(&self, unidirectional: bool) -> u64
pub fn flow_id(&self, unidirectional: bool) -> u64
Compute a deterministic 64-bit flow ID using rapidhash.
Bidirectional (default): A→B and B→A produce the same ID by
canonicalising the two endpoints so that min_ep always comes first.
Unidirectional: hash the 5-tuple as-is, direction-sensitive.
IPs are serialised as fixed-width big-endian bytes (4 for IPv4, 16 for IPv6) prefixed with a family tag to prevent collisions between address families.
Trait Implementations§
impl Eq for FlowKey
impl StructuralPartialEq for FlowKey
Auto Trait Implementations§
impl Freeze for FlowKey
impl RefUnwindSafe for FlowKey
impl Send for FlowKey
impl Sync for FlowKey
impl Unpin for FlowKey
impl UnsafeUnpin for FlowKey
impl UnwindSafe for FlowKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more