pub struct Map<K, V>{ /* private fields */ }
Expand description
Map of bit strings (combined to prefixes) to values
Each bit string can only have a single value; sibling bit strings mapping to the same value are automatically merged internally.
This is implemented as a crate::tree::Tree
where only leaf nodes carry values.
Implementations§
source§impl<K, V> Map<K, V>
impl<K, V> Map<K, V>
sourcepub fn insert(&mut self, prefix: K, value: V)
pub fn insert(&mut self, prefix: K, value: V)
Set new value for all bit strings with given prefix
sourcepub fn get(&self, key: &K) -> Option<&V>
pub fn get(&self, key: &K) -> Option<&V>
Lookup value for a bit string
If only a prefix for longer values is given this only finds an aggregated value, i.e. lookups should usually be done using a “full-length” bit string. (E.g. lookup single hosts in a CIDR-map.)
sourcepub fn iter(&self) -> IterMap<'_, K, V> ⓘ
pub fn iter(&self) -> IterMap<'_, K, V> ⓘ
Iterate over all (aggregated) prefixes and their values
sourcepub fn iter_mut(&mut self) -> IterMutMap<'_, K, V> ⓘ
pub fn iter_mut(&mut self) -> IterMutMap<'_, K, V> ⓘ
Iterate over all (aggregated) prefixes and their mutable values
sourcepub fn iter_full(&self) -> IterMapFull<'_, K, V> ⓘ
pub fn iter_full(&self) -> IterMapFull<'_, K, V> ⓘ
Iterate over smallest list of bit strings that cover everything with a value or None if not mapped
Trait Implementations§
Auto Trait Implementations§
impl<K, V> Freeze for Map<K, V>
impl<K, V> RefUnwindSafe for Map<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for Map<K, V>
impl<K, V> Sync for Map<K, V>
impl<K, V> Unpin for Map<K, V>
impl<K, V> UnwindSafe for Map<K, V>where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)