Struct safe_network::messaging::node::PrefixMap[][src]

pub struct PrefixMap<T>(_)
where
    T: Borrow<Prefix>
;
Expand description

Container that acts as a map whose keys are prefixes.

It differs from a normal map of Prefix -> T in a couple of ways:

  1. It allows to keep the prefix and the value in the same type which makes it internally more similar to a set of (Prefix, T) rather than map of Prefix -> T while still providing convenient map-like API
  2. It automatically prunes redundant entries. That is, when the prefix of an entry is fully covered by other prefixes, that entry is removed. For example, when there is entry with prefix (00) and we insert entries with (000) and (001), the (00) prefix becomes fully covered and is automatically removed.
  3. It provides some additional lookup API for convenience (get_equal_or_ancestor, get_matching, …)

Implementations

Create empty PrefixMap.

Inserts new entry into the map. Replaces previous entry at the same prefix. Removes those ancestors of the inserted prefix that are now fully covered by their descendants. Does not insert anything if any descendant of the prefix of entry is already present in the map. Returns the previous entry with the same prefix, if any.

Get the entry at prefix, if any.

Get the entry at prefix or any of its ancestors. In case of multiple matches, returns the one with the longest prefix.

Get the entry at the prefix that matches name. In case of multiple matches, returns the one with the longest prefix.

Returns an iterator over the entries, in order by prefixes.

Returns an iterator over all entries whose prefixes are descendants (extensions) of prefix.

Trait Implementations

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

Performs the conversion.

Creates a value from an iterator. Read more

Feeds this value into the given Hasher. Read more

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

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

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

This method tests for !=.

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

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.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

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.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more