Struct sn_messaging::node::PrefixMap [−][src]
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:
- 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 ofPrefix
->T
while still providing convenient map-like API - 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.
- It provides some additional lookup API for convenience (
get_equal_or_ancestor
,get_matching
, …)
Implementations
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
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.
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Creates a value from an iterator. Read more
Auto Trait Implementations
impl<T> RefUnwindSafe for PrefixMap<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for PrefixMap<T> where
T: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self
pub fn vzip(self) -> V