Struct bc_envelope::prelude::Map
source · pub struct Map(/* private fields */);Expand description
A CBOR map.
Keys are kept sorted by encoded CBOR form in ascending lexicographic order.
Implementations§
source§impl Map
impl Map
pub fn is_empty(&self) -> bool
sourcepub fn iter(&self) -> MapIter<'_>
pub fn iter(&self) -> MapIter<'_>
Gets an iterator over the entries of the CBOR map, sorted by key.
Key sorting order is lexicographic by the key’s binary-encoded CBOR.
sourcepub fn insert(&mut self, key: impl Into<CBOR>, value: impl Into<CBOR>)
pub fn insert(&mut self, key: impl Into<CBOR>, value: impl Into<CBOR>)
Inserts a key-value pair into the map.
sourcepub fn get<K, V>(&self, key: K) -> Option<V>where
K: CBOREncodable,
V: CBORDecodable,
pub fn get<K, V>(&self, key: K) -> Option<V>where
K: CBOREncodable,
V: CBORDecodable,
Get a value from the map, given a key.
Returns Some if the key is present in the map, None otherwise.
sourcepub fn extract<K, V>(&self, key: K) -> Result<V, CBORError>where
K: CBOREncodable,
V: CBORDecodable,
pub fn extract<K, V>(&self, key: K) -> Result<V, CBORError>where
K: CBOREncodable,
V: CBORDecodable,
Get a value from the map, given a key.
Returns Ok if the key is present in the map, Err otherwise.
Trait Implementations§
source§impl CBOREncodable for Map
impl CBOREncodable for Map
source§impl<T, K, V> From<T> for Map
impl<T, K, V> From<T> for Map
Convert a container to a CBOR Map where the container’s items are pairs of CBOREncodable values.
impl Eq for Map
Auto Trait Implementations§
impl Freeze for Map
impl RefUnwindSafe for Map
impl Send for Map
impl Sync for Map
impl Unpin for Map
impl UnwindSafe for Map
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