Trait prefix_trie::Prefix
source · pub trait Prefix: Sized {
type R: Unsigned + PrimInt + Zero + CheckedShr;
fn repr(&self) -> Self::R;
fn prefix_len(&self) -> u8;
fn from_repr_len(repr: Self::R, len: u8) -> Self;
fn mask(&self) -> Self::R { ... }
fn zero() -> Self { ... }
fn longest_common_prefix(&self, other: &Self) -> Self { ... }
fn contains(&self, other: &Self) -> bool { ... }
fn is_bit_set(&self, bit: u8) -> bool { ... }
fn eq(&self, other: &Self) -> bool { ... }
}Expand description
Trait for defining prefixes.
Required Associated Types§
Required Methods§
sourcefn repr(&self) -> Self::R
fn repr(&self) -> Self::R
Get raw representation of the address, ignoring the prefix length. This function must return the representation with the mask already applied.
sourcefn prefix_len(&self) -> u8
fn prefix_len(&self) -> u8
Prefix length
sourcefn from_repr_len(repr: Self::R, len: u8) -> Self
fn from_repr_len(repr: Self::R, len: u8) -> Self
Create a new prefix from the representation and the prefix pength.
Provided Methods§
sourcefn mask(&self) -> Self::R
fn mask(&self) -> Self::R
mask self.repr() using self.len(). If you can guarantee that repr is already masked,
them simply re-implement this function for your type.
sourcefn longest_common_prefix(&self, other: &Self) -> Self
fn longest_common_prefix(&self, other: &Self) -> Self
longest common prefix
sourcefn contains(&self, other: &Self) -> bool
fn contains(&self, other: &Self) -> bool
Check if self contains other in its prefix range. This function also returns True if
self is identical to other.
sourcefn is_bit_set(&self, bit: u8) -> bool
fn is_bit_set(&self, bit: u8) -> bool
Check if a specific bit is set (counted from the left, where 0 is the first bit from the left).