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]

pub fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), Error>[src]

Formats the value using the given formatter.

impl Clone for Prefix[src]

pub fn clone(&self) -> Prefix[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Prefix[src]

pub fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), Error>[src]

Formats the value using the given formatter. Read more

impl Default for Prefix[src]

pub fn default() -> Prefix[src]

Returns the “default value” for a type. Read more

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]

Deserialize this value from the given Serde deserializer. Read more

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]

Parses a string s to return a value of this type. Read more

impl Hash for Prefix[src]

pub fn hash<H>(&self, state: &mut H) where
    H: Hasher
[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl Ord for Prefix[src]

pub fn cmp(&self, other: &Prefix) -> Ordering[src]

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl PartialEq<Prefix> for Prefix[src]

pub fn eq(&self, other: &Prefix) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialOrd<Prefix> for Prefix[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]

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]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

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]

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> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[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]

pub fn equivalent(&self, key: &K) -> bool[src]

Compare self to key and return true if they are equal.

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

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[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]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

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]

🔬 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<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

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]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

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

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