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§

How can the prefix be represented. This must be one of u8, u16, u32, u64, or u128.

Required Methods§

Get raw representation of the address, ignoring the prefix length. This function must return the representation with the mask already applied.

Prefix length

Create a new prefix from the representation and the prefix pength.

Provided Methods§

mask self.repr() using self.len(). If you can guarantee that repr is already masked, them simply re-implement this function for your type.

Create a prefix that matches everything

longest common prefix

Check if self contains other in its prefix range. This function also returns True if self is identical to other.

Check if a specific bit is set (counted from the left, where 0 is the first bit from the left).

Compare two prefixes together

Implementations on Foreign Types§

Implementors§