Struct routing::Prefix [−][src]
A section prefix, i.e. a sequence of bits specifying the part of the network's name space consisting of all names that start with this sequence.
Methods
impl<T: Clone + Copy + Default + Binary + Xorable> Prefix<T>
[src]
impl<T: Clone + Copy + Default + Binary + Xorable> Prefix<T>
pub fn new(bit_count: usize, name: T) -> Prefix<T>
[src]
pub fn new(bit_count: usize, name: T) -> Prefix<T>
Creates a new Prefix
with the first bit_count
bits of name
. Insignificant bits are all
set to 0. If bit_count
exceeds the size of T
in bits, then it is reduced to this lower
value.
pub fn with_version(self, version: u64) -> VersionedPrefix<T>
[src]
pub fn with_version(self, version: u64) -> VersionedPrefix<T>
Returns a VersionedPrefix
with this prefix and the given version number.
pub fn pushed(self, bit: bool) -> Prefix<T>
[src]
pub fn pushed(self, bit: bool) -> Prefix<T>
Returns self
with an appended bit: 0
if bit
is false
, and 1
if bit
is true
. If
self.bit_count
is already at the maximum for this type, then an unmodified copy of self
is returned.
pub fn popped(self) -> Prefix<T>
[src]
pub fn popped(self) -> Prefix<T>
Returns a prefix copying the first bitcount() - 1
bits from self
,
or self
if it is already empty.
pub fn bit_count(&self) -> usize
[src]
pub fn bit_count(&self) -> usize
Returns the number of bits in the prefix.
pub fn is_compatible(&self, other: &Prefix<T>) -> bool
[src]
pub fn is_compatible(&self, other: &Prefix<T>) -> bool
Returns true
if self
is a prefix of other
or vice versa.
pub fn is_extension_of(&self, other: &Prefix<T>) -> bool
[src]
pub fn is_extension_of(&self, other: &Prefix<T>) -> bool
Returns true
if other
is compatible but strictly shorter than self
.
pub fn is_neighbour(&self, other: &Prefix<T>) -> bool
[src]
pub fn is_neighbour(&self, other: &Prefix<T>) -> bool
Returns true
if the other
prefix differs in exactly one bit from this one.
pub fn common_prefix(&self, name: &T) -> usize
[src]
pub fn common_prefix(&self, name: &T) -> usize
Returns the number of common leading bits with the input name, capped with prefix length.
pub fn matches(&self, name: &T) -> bool
[src]
pub fn matches(&self, name: &T) -> bool
Returns true
if this is a prefix of the given name
.
pub fn cmp_distance(&self, other: &Self, target: &T) -> Ordering
[src]
pub fn cmp_distance(&self, other: &Self, target: &T) -> Ordering
Compares the distance of self
and other
to target
. Returns Less
if self
is closer,
Greater
if other
is closer, and compares the prefix directly if of equal distance
(this is to make sorting deterministic).
pub fn lower_bound(&self) -> T
[src]
pub fn lower_bound(&self) -> T
Returns the smallest name matching the prefix
pub fn upper_bound(&self) -> T
[src]
pub fn upper_bound(&self) -> T
Returns the largest name matching the prefix
pub fn is_covered_by<'a, U>(&self, prefixes: U) -> bool where
T: 'a,
U: IntoIterator<Item = &'a Prefix<T>> + Clone,
[src]
pub fn is_covered_by<'a, U>(&self, prefixes: U) -> bool where
T: 'a,
U: IntoIterator<Item = &'a Prefix<T>> + Clone,
Returns whether the namespace defined by self
is covered by prefixes in the prefixes
set
pub fn with_flipped_bit(&self, i: usize) -> Prefix<T>
[src]
pub fn with_flipped_bit(&self, i: usize) -> Prefix<T>
Returns the neighbouring prefix differing in the i
-th bit
If i
is larger than our bit count, self
is returned
pub fn substituted_in(&self, name: T) -> T
[src]
pub fn substituted_in(&self, name: T) -> T
Returns the given name
with first bits replaced by self
pub fn sibling(&self) -> Prefix<T>
[src]
pub fn sibling(&self) -> Prefix<T>
Returns the same prefix, with the last bit flipped, or unchanged, if empty.
Trait Implementations
impl<T: Clone + Clone + Copy + Default + Binary + Xorable> Clone for Prefix<T>
[src]
impl<T: Clone + Clone + Copy + Default + Binary + Xorable> Clone for Prefix<T>
fn clone(&self) -> Prefix<T>
[src]
fn clone(&self) -> Prefix<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T: Copy + Clone + Copy + Default + Binary + Xorable> Copy for Prefix<T>
[src]
impl<T: Copy + Clone + Copy + Default + Binary + Xorable> Copy for Prefix<T>
impl<T: Default + Clone + Copy + Default + Binary + Xorable> Default for Prefix<T>
[src]
impl<T: Default + Clone + Copy + Default + Binary + Xorable> Default for Prefix<T>
impl<T: Eq + Clone + Copy + Default + Binary + Xorable> Eq for Prefix<T>
[src]
impl<T: Eq + Clone + Copy + Default + Binary + Xorable> Eq for Prefix<T>
impl<T: Clone + Copy + Default + Binary + Xorable> PartialEq<Prefix<T>> for Prefix<T>
[src]
impl<T: Clone + Copy + Default + Binary + Xorable> PartialEq<Prefix<T>> for Prefix<T>
fn eq(&self, other: &Self) -> bool
[src]
fn eq(&self, other: &Self) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<T: Clone + Copy + Default + Binary + Xorable> PartialOrd<Prefix<T>> for Prefix<T>
[src]
impl<T: Clone + Copy + Default + Binary + Xorable> PartialOrd<Prefix<T>> for Prefix<T>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
fn gt(&self, other: &Rhs) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
fn ge(&self, other: &Rhs) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T: Clone + Copy + Default + Binary + Xorable> Ord for Prefix<T>
[src]
impl<T: Clone + Copy + Default + Binary + Xorable> Ord for Prefix<T>
fn cmp(&self, other: &Self) -> Ordering
[src]
fn cmp(&self, other: &Self) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl<T: Clone + Copy + Default + Binary + Xorable> Hash for Prefix<T>
[src]
impl<T: Clone + Copy + Default + Binary + Xorable> Hash for Prefix<T>
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash<H: Hasher>(&self, state: &mut H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T: Clone + Copy + Default + Binary + Xorable> Binary for Prefix<T>
[src]
impl<T: Clone + Copy + Default + Binary + Xorable> Binary for Prefix<T>
fn fmt(&self, formatter: &mut Formatter) -> FmtResult
[src]
fn fmt(&self, formatter: &mut Formatter) -> FmtResult
Formats the value using the given formatter.
impl<T: Clone + Copy + Default + Binary + Xorable> Debug for Prefix<T>
[src]
impl<T: Clone + Copy + Default + Binary + Xorable> Debug for Prefix<T>