Struct bc_ur::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

source

pub fn new() -> Map

Makes a new, empty CBOR Map.

source

pub fn len(&self) -> usize

Returns the number of entries in the map.

source

pub fn is_empty(&self) -> bool

source

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.

source

pub fn insert(&mut self, key: impl Into<CBOR>, value: impl Into<CBOR>)

Inserts a key-value pair into the map.

source

pub fn get<K, V>(&self, key: K) -> Option<V>

Get a value from the map, given a key.

Returns Some if the key is present in the map, None otherwise.

source

pub fn extract<K, V>(&self, key: K) -> Result<V, CBORError>

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

source§

fn cbor(&self) -> CBOR

Returns the value in CBOR symbolic representation.
source§

fn cbor_data(&self) -> Vec<u8>

Returns the value in CBOR binary representation.
source§

impl Clone for Map

source§

fn clone(&self) -> Map

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Map

source§

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

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

impl Default for Map

source§

fn default() -> Map

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

impl From<Map> for CBOR

source§

fn from(value: Map) -> CBOR

Converts to this type from the input type.
source§

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.

source§

fn from(container: T) -> Map

Converts to this type from the input type.
source§

impl PartialEq for Map

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Map

Auto Trait Implementations§

§

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> 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> 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,

§

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>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.