#[repr(transparent)]pub struct BaseIndex(pub NonZeroU8);Expand description
A “base index” as described in Hariguchi’s ART paper; a linearized address for a prefix/octet tuple when considering the hierarchy of possible prefixes for a given 8-bit address.
Note that this only covers up to /7, fringes (/8s) would require a ninth
bit, which is encoded structurally in the trie as children (vs
prefixes).
Tuple Fields§
§0: NonZeroU8Implementations§
Source§impl BaseIndex
impl BaseIndex
Sourcepub const fn try_new(val: u8) -> Option<Self>
pub const fn try_new(val: u8) -> Option<Self>
Construct a new index value. Fails if the value is zero.
Sourcepub const fn from_prefix(octet: u8, prefix_len: u8) -> Self
pub const fn from_prefix(octet: u8, prefix_len: u8) -> Self
Maps 8-bit prefixes to numbers. The prefixes range from 0/0 to 255/7. Return values range from 1 to 255.
§Panics
If prefix_len >= 8.
Sourcepub const fn from_pfx_7(octet: u8) -> Self
pub const fn from_pfx_7(octet: u8) -> Self
Maps octet/7 prefixes to indices in 128..255. Optimization over
Self::from_prefix which saves a little bit of math if the prefix
length is known to be /7.
Sourcepub const fn prefix(self) -> (u8, u8)
pub const fn prefix(self) -> (u8, u8)
Computes the octet and prefix len of this index.
Inverse of Self::from_prefix.
Sourcepub const fn prefix_bits(&self, depth: usize) -> u8
pub const fn prefix_bits(&self, depth: usize) -> u8
Compute the bit position of a prefix represented by this index at a given trie depth.
Sourcepub const fn range(&self) -> RangeInclusive<u8>
pub const fn range(&self) -> RangeInclusive<u8>
Range of octets covered by this index.
This base index encodes a prefix of up to 8 bits inside a single stride (octet). This function computes the numerical start and end of the value range for that prefix.
Sourcepub const fn len(&self) -> u8
pub const fn len(&self) -> u8
Like go’s bits.Len8: compute the number of bits required to represent
this index.
Sourcepub const fn fmt_prefix(&self) -> impl Debug + use<>
pub const fn fmt_prefix(&self) -> impl Debug + use<>
Return a formatter for prefix notation: addr/len.