Struct sn_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.
Implementations
impl 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 name(&self) -> XorName
[src]
Returns the name of this prefix.
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]
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]
Returns the number of bits in the prefix.
pub fn is_empty(&self) -> bool
[src]
Returns true
if this is the empty prefix, with no bits.
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]
Returns true
if other
is compatible but strictly shorter than self
.
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]
Returns the number of common leading bits with the input name, capped with prefix length.
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]
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]
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]
Returns the smallest name matching the prefix
pub fn upper_bound(&self) -> XorName
[src]
Returns the largest name matching the prefix
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]
I: IntoIterator<Item = &'a Prefix> + Clone,
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]
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]
Returns the given name
with first bits replaced by self
pub fn sibling(&self) -> Prefix
[src]
Returns the same prefix, with the last bit flipped, or unchanged, if empty.
pub fn ancestor(&self, bit_count: u8) -> Prefix
[src]
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.
pub fn ancestors(&self) -> Ancestors
[src]
Returns an iterator that yields all ancestors of this prefix.
Trait Implementations
impl Binary for Prefix
[src]
impl Clone for Prefix
[src]
impl Copy for Prefix
[src]
impl Debug for Prefix
[src]
impl Default 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]
__deserializer: __D
) -> Result<Prefix, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
impl Eq for Prefix
[src]
impl FromStr for Prefix
[src]
type Err = FromStrError
The associated error which can be returned from parsing.
pub fn from_str(bits: &str) -> Result<Prefix, <Prefix as FromStr>::Err>
[src]
impl Hash for Prefix
[src]
pub fn hash<H>(&self, state: &mut H) where
H: Hasher,
[src]
H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for Prefix
[src]
pub fn cmp(&self, other: &Prefix) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<Prefix> for Prefix
[src]
pub fn eq(&self, other: &Prefix) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<Prefix> for Prefix
[src]
pub fn partial_cmp(&self, other: &Prefix) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[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]
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
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<A> Actor for A where
A: Ord + Clone + Hash,
A: Ord + Clone + Hash,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Member for T where
T: Clone + Hash + Eq,
T: Clone + Hash + Eq,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,