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]

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]

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]

impl Eq for Prefix[src]

impl FromStr for Prefix[src]

type Err = FromStrError

The associated error which can be returned from parsing.

impl Hash for Prefix[src]

impl Ord for Prefix[src]

impl PartialEq<Prefix> for Prefix[src]

impl PartialOrd<Prefix> for Prefix[src]

impl Serialize 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<A> Actor for A where
    A: Ord + Clone + Hash

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,