Skip to main content

Map

Struct Map 

Source
pub struct Map<K: Zeroize, V: Zeroize>(/* private fields */);
Available on crate feature zeroize only.
Expand description

An ordered map with keys and values in stable wipe-owned allocations.

Tree balancing only moves pointers. Key order is deterministic and lookup has logarithmic worst-case cost, including in no_std without random seeds.

Implementations§

Source§

impl<K: Zeroize, V: Zeroize> Map<K, V>

Source

pub fn len(&self) -> usize

Number of entries.

Source

pub fn is_empty(&self) -> bool

Whether the map is empty.

Source

pub fn iter(&self) -> Iter<'_, K, V>

Borrow entries in ascending key order.

Source

pub fn keys(&self) -> impl DoubleEndedIterator<Item = &K> + ExactSizeIterator

Borrow keys in ascending order.

Source

pub fn values(&self) -> impl DoubleEndedIterator<Item = &V> + ExactSizeIterator

Borrow values in ascending key order.

Source

pub fn values_mut( &mut self, ) -> impl DoubleEndedIterator<Item = &mut V> + ExactSizeIterator

Mutably borrow values in place, without moving their stable slots.

Source

pub fn clear(&mut self)

Wipe and remove every entry.

Source§

impl<K: Zeroize + Ord, V: Zeroize> Map<K, V>

Source

pub fn insert(&mut self, key: K, value: V)

Insert a value, wiping a replaced value and any redundant key before release.

Source

pub fn get<Q: Ord + ?Sized>(&self, key: &Q) -> Option<&V>
where MapKey<K>: Borrow<Q>,

Find a value by its key, a borrowed string, or borrowed bytes.

Source

pub fn get_mut<Q: Ord + ?Sized>(&mut self, key: &Q) -> Option<&mut V>
where MapKey<K>: Borrow<Q>,

Mutably borrow an existing value without moving its storage.

Trait Implementations§

Source§

impl<K: Zeroize + Ord + Clone, V: Zeroize + Clone> Clone for Map<K, V>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: Zeroize, V: Zeroize> Debug for Map<K, V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K: Zeroize, V: Zeroize> Default for Map<K, V>

Source§

fn default() -> Self

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

impl<'de, K: Zeroize + Ord + Deserialize<'de>, V: Zeroize + Deserialize<'de>> Deserialize<'de> for Map<K, V>

Available on crate feature json only.
Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<K: Zeroize, V: Zeroize> Drop for Map<K, V>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<K: Zeroize + Ord, V: Zeroize + Eq> Eq for Map<K, V>

Source§

impl<K: Zeroize + Ord, V: Zeroize> FromIterator<(K, V)> for Map<K, V>

Source§

fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<'a, K: Zeroize, V: Zeroize> IntoIterator for &'a Map<K, V>

Source§

type Item = (&'a K, &'a V)

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, K, V>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<K: Zeroize + Ord, V: Zeroize> MapStorage for Map<K, V>

Source§

type Key = K

The map key type.
Source§

type Value = V

The map value type.
Source§

fn storage_len(&self) -> usize

Number of entries.
Source§

fn storage_insert(&mut self, key: K, value: V)

Insert one entry (last-write-wins, matching proto map-merge semantics).
Source§

fn storage_clear(&mut self)

Remove all entries (the field’s cleared / default state), retaining capacity where the underlying type allows. Invoked by the generated message clear().
Source§

fn storage_erase_key(key: &mut K)

Erase a key discarded before insertion, including after a later parse error. A wipe-owning container overrides this; ordinary containers keep the default. Implementations must not panic or allocate. Called by binary and JSON map decoders when the zeroize feature is enabled, including the table codec’s partial and discarded entries. With that feature disabled, temporary slots use ordinary Rust drop.
Source§

fn storage_erase_value(value: &mut V)

Erase a value discarded before insertion. Implementations must not panic or allocate. Like storage_erase_key, this hook runs only with the zeroize feature.
Source§

fn storage_iter<'a>(&'a self) -> impl Iterator<Item = (&'a K, &'a V)>
where K: 'a, V: 'a,

Borrow-iterate entries in the container’s native order.
Source§

impl<K: Zeroize + Ord, V: Zeroize + PartialEq> PartialEq for Map<K, V>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<K: Zeroize + Serialize, V: Zeroize + Serialize> Serialize for Map<K, V>

Available on crate feature json only.
Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl<K: Zeroize, V: Zeroize> Zeroize for Map<K, V>

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
Source§

impl<K: Zeroize, V: Zeroize> ZeroizeOnDrop for Map<K, V>

Auto Trait Implementations§

§

impl<K, V> Forget for Map<K, V>

§

impl<K, V> Freeze for Map<K, V>
where BTreeMap<MapKey<K>, Box<Zeroizing<V>>>: Freeze,

§

impl<K, V> Move for Map<K, V>

§

impl<K, V> RefUnwindSafe for Map<K, V>
where BTreeMap<MapKey<K>, Box<Zeroizing<V>>>: RefUnwindSafe,

§

impl<K, V> Send for Map<K, V>
where BTreeMap<MapKey<K>, Box<Zeroizing<V>>>: Send,

§

impl<K, V> Sync for Map<K, V>
where BTreeMap<MapKey<K>, Box<Zeroizing<V>>>: Sync,

§

impl<K, V> Unpin for Map<K, V>
where BTreeMap<MapKey<K>, Box<Zeroizing<V>>>: Unpin,

§

impl<K, V> UnsafeUnpin for Map<K, V>
where BTreeMap<MapKey<K>, Box<Zeroizing<V>>>: UnsafeUnpin,

§

impl<K, V> UnwindSafe for Map<K, V>
where BTreeMap<MapKey<K>, Box<Zeroizing<V>>>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

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

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.