Struct safe_network::routing::Prefix [−][src]
pub struct Prefix { /* fields omitted */ }
Expand description
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.
Implementations
Creates a new Prefix
with the first bit_count
bits of name
. Insignificant bits are all
set to 0.
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.
Returns a prefix copying the first bitcount() - 1
bits from self
,
or self
if it is already empty.
Returns true
if self
is a prefix of other
or vice versa.
Returns true
if other
is compatible but strictly shorter than self
.
Returns true
if the other
prefix differs in exactly one bit from this one.
Returns the number of common leading bits with the input name, capped with prefix length.
Returns true
if this is a prefix of the given name
.
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).
Compares the prefixes using breadth-first order. That is, shorter prefixes are ordered
before longer. This is in contrast with the default Ord
impl of Prefix
which uses
depth-first order.
Returns the smallest name matching the prefix
Returns the largest name matching the prefix
Inclusive range from lower_bound to upper_bound
pub fn is_covered_by<'a, I>(&self, prefixes: I) -> bool where
I: IntoIterator<Item = &'a Prefix> + Clone,
pub fn is_covered_by<'a, I>(&self, prefixes: I) -> bool where
I: IntoIterator<Item = &'a Prefix> + Clone,
Returns whether the namespace defined by self
is covered by prefixes in the prefixes
set
Returns the neighbouring prefix differing in the i
-th bit
If i
is larger than our bit count, self
is returned
Returns the given name
with first bits replaced by self
Returns the same prefix, with the last bit flipped, or unchanged, if empty.
Returns the ancestors of this prefix that has the given bit count.
Panics
Panics if bit_count
is not less than the bit count of this prefix.
Trait Implementations
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<Prefix, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<Prefix, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for Prefix
impl UnwindSafe for Prefix
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self
pub fn vzip(self) -> V