Struct sn_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 the name of this prefix.

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 the number of bits in the prefix.

Returns true if this is the empty prefix, with no bits.

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

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.

Returns an iterator that yields all ancestors of this prefix.

Trait Implementations

Formats the value using the given formatter.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Deserialize this value from the given Serde deserializer. Read more

The associated error which can be returned from parsing.

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

Feeds this value into the given Hasher. Read more

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

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

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

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

This method tests for !=.

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

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

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

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

Performs the conversion.

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

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

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.