Struct sn_routing::Prefix [−][src]
pub struct Prefix { /* 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.
Implementations
impl Prefix
[src]
impl Prefix
[src]pub fn new(bit_count: usize, name: XorName) -> Prefix
[src]
pub fn new(bit_count: usize, name: XorName) -> Prefix
[src]Creates a new Prefix
with the first bit_count
bits of name
. Insignificant bits are all
set to 0.
pub fn pushed(self, bit: bool) -> Prefix
[src]
pub fn pushed(self, bit: bool) -> Prefix
[src]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
[src]
pub fn popped(self) -> Prefix
[src]Returns a prefix copying the first bitcount() - 1
bits from self
,
or self
if it is already empty.
pub fn is_compatible(&self, other: &Prefix) -> bool
[src]
pub fn is_compatible(&self, other: &Prefix) -> bool
[src]Returns true
if self
is a prefix of other
or vice versa.
pub fn is_extension_of(&self, other: &Prefix) -> bool
[src]
pub fn is_extension_of(&self, other: &Prefix) -> bool
[src]Returns true
if other
is compatible but strictly shorter than self
.
pub fn is_neighbour(&self, other: &Prefix) -> bool
[src]
pub fn is_neighbour(&self, other: &Prefix) -> bool
[src]Returns true
if the other
prefix differs in exactly one bit from this one.
pub fn common_prefix(&self, name: &XorName) -> usize
[src]
pub fn common_prefix(&self, name: &XorName) -> usize
[src]Returns the number of common leading bits with the input name, capped with prefix length.
pub fn matches(&self, name: &XorName) -> bool
[src]
pub fn matches(&self, name: &XorName) -> bool
[src]Returns true
if this is a prefix of the given name
.
pub fn cmp_distance(&self, other: &Prefix, target: &XorName) -> Ordering
[src]
pub fn cmp_distance(&self, other: &Prefix, target: &XorName) -> Ordering
[src]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 cmp_breadth_first(&self, other: &Prefix) -> Ordering
[src]
pub fn cmp_breadth_first(&self, other: &Prefix) -> Ordering
[src]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.
pub fn lower_bound(&self) -> XorName
[src]
pub fn lower_bound(&self) -> XorName
[src]Returns the smallest name matching the prefix
pub fn upper_bound(&self) -> XorName
[src]
pub fn upper_bound(&self) -> XorName
[src]Returns the largest name matching the prefix
pub fn range_inclusive(&self) -> RangeInclusive<XorName>
[src]
pub fn range_inclusive(&self) -> RangeInclusive<XorName>
[src]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,
[src]
pub fn is_covered_by<'a, I>(&self, prefixes: I) -> bool where
I: IntoIterator<Item = &'a Prefix> + Clone,
[src]Returns whether the namespace defined by self
is covered by prefixes in the prefixes
set
pub fn with_flipped_bit(&self, i: u8) -> Prefix
[src]
pub fn with_flipped_bit(&self, i: u8) -> Prefix
[src]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: XorName) -> XorName
[src]
pub fn substituted_in(&self, name: XorName) -> XorName
[src]Returns the given name
with first bits replaced by self
pub fn sibling(&self) -> Prefix
[src]
pub fn sibling(&self) -> Prefix
[src]Returns the same prefix, with the last bit flipped, or unchanged, if empty.
Trait Implementations
impl<'de> Deserialize<'de> for Prefix
[src]
impl<'de> Deserialize<'de> for Prefix
[src]pub fn deserialize<__D>(
__deserializer: __D
) -> Result<Prefix, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
[src]
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<Prefix, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
[src]Deserialize this value from the given Serde deserializer. Read more
impl Ord for Prefix
[src]
impl Ord for Prefix
[src]impl PartialOrd<Prefix> for Prefix
[src]
impl PartialOrd<Prefix> for Prefix
[src]pub fn partial_cmp(&self, other: &Prefix) -> Option<Ordering>
[src]
pub fn partial_cmp(&self, other: &Prefix) -> Option<Ordering>
[src]This method returns an ordering between self
and other
values if one exists. Read more
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Serialize for Prefix
[src]
impl Serialize for Prefix
[src]pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
[src]
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
[src]Serialize this value into the given Serde serializer. Read more
impl Copy for Prefix
[src]
impl Eq for Prefix
[src]
impl StructuralEq for Prefix
[src]
Auto Trait Implementations
impl RefUnwindSafe for Prefix
impl Send for Prefix
impl Sync for Prefix
impl Unpin for Prefix
impl UnwindSafe for Prefix
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]pub fn equivalent(&self, key: &K) -> bool
[src]
pub fn equivalent(&self, key: &K) -> bool
[src]Compare self to key
and return true
if they are equal.
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<A> Actor for A where
A: Ord + Clone + Hash,
A: Ord + Clone + Hash,
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,