Struct routing::Prefix
[−]
[src]
pub struct Prefix<T: Clone + Copy + Default + Binary + Xorable> { /* fields omitted */ }
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]
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.
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.
fn popped(self) -> Prefix<T>
Returns a prefix copying the first bitcount() - 1 bits from self,
or self if it is already empty.
fn bit_count(&self) -> usize
Returns the number of bits in the prefix.
fn is_compatible(&self, other: &Prefix<T>) -> bool
Returns true if self is a prefix of other or vice versa.
fn is_neighbour(&self, other: &Prefix<T>) -> bool
Returns true if the other prefix differs in exactly one bit from this one.
fn common_prefix(&self, name: &T) -> usize
Returns the number of common leading bits with the input name, capped with prefix length.
fn max_identical_index(&self, name: &T) -> usize
Returns the number of common leading bits with the input name.
fn matches(&self, name: &T) -> bool
Returns true if this is a prefix of the given name.
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).
fn lower_bound(&self) -> T
Returns the smallest name matching the prefix
fn upper_bound(&self) -> T
Returns the largest name matching the prefix
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
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
fn substituted_in(&self, name: T) -> T
Returns the given name with first bits replaced by self
Trait Implementations
impl<T: Clone + Clone + Copy + Default + Binary + Xorable> Clone for 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
Performs copy-assignment from source. Read more
impl<T: Copy + Clone + Copy + Default + Binary + Xorable> Copy for Prefix<T>[src]
impl<T: Default + Clone + Copy + Default + Binary + Xorable> Default for Prefix<T>[src]
impl<T: Eq + Clone + Copy + Default + Binary + Xorable> Eq for Prefix<T>[src]
impl<T: Decodable + Clone + Copy + Default + Binary + Xorable> Decodable for Prefix<T>[src]
fn decode<__DT: Decoder>(__arg_0: &mut __DT) -> Result<Prefix<T>, __DT::Error>
Deserialize a value using a Decoder.
impl<T: Encodable + Clone + Copy + Default + Binary + Xorable> Encodable for Prefix<T>[src]
fn encode<__ST: Encoder>(&self, __arg_0: &mut __ST) -> Result<(), __ST::Error>
Serialize a value using an Encoder.
impl<T: Clone + Copy + Default + Binary + Xorable> PartialEq<Prefix<T>> for Prefix<T>[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) -> bool1.0.0
This method tests for !=.
impl<T: Clone + Copy + Default + Binary + Xorable> PartialOrd<Prefix<T>> for Prefix<T>[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) -> bool1.0.0
This method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, other: &Rhs) -> bool1.0.0
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) -> bool1.0.0
This method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, other: &Rhs) -> bool1.0.0
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]
fn cmp(&self, other: &Self) -> Ordering
This method returns an Ordering between self and other. Read more
impl<T: Clone + Copy + Default + Binary + Xorable> Hash for Prefix<T>[src]
fn hash<H: Hasher>(&self, state: &mut H)
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher1.3.0
Feeds a slice of this type into the state provided.