[−]Struct near_sdk::collections::Map
An iterable implementation of a map that stores its content directly on the trie.
Methods
impl<K, V> Map<K, V>
[src]
pub fn len(&self) -> u64
[src]
Returns the number of elements in the map, also referred to as its size.
pub fn new(id: Vec<u8>) -> Self
[src]
Create new map with zero elements. Use id
as a unique identifier.
pub fn insert_raw(
&mut self,
key_raw: &[u8],
value_raw: &[u8]
) -> Option<Vec<u8>>
[src]
&mut self,
key_raw: &[u8],
value_raw: &[u8]
) -> Option<Vec<u8>>
Inserts a serialized key-value pair into the map.
If the map did not have this key present, None
is returned. Otherwise returns
a serialized value. Note, the keys that have the same hash value are undistinguished by
the implementation.
pub fn remove_raw(&mut self, key_raw: &[u8]) -> Option<Vec<u8>>
[src]
Removes a serialized key from the map, returning the serialized value at the key if the key was previously in the map.
impl<K, V> Map<K, V> where
K: BorshSerialize + BorshDeserialize,
V: BorshSerialize + BorshDeserialize,
[src]
K: BorshSerialize + BorshDeserialize,
V: BorshSerialize + BorshDeserialize,
pub fn get(&self, key: &K) -> Option<V>
[src]
Returns the value corresponding to the key.
pub fn remove(&mut self, key: &K) -> Option<V>
[src]
Removes a key from the map, returning the value at the key if the key was previously in the map.
pub fn insert(&mut self, key: &K, value: &V) -> Option<V>
[src]
Inserts a key-value pair into the map.
If the map did not have this key present, None
is returned. Otherwise returns
a value. Note, the keys that have the same hash value are undistinguished by
the implementation.
pub fn clear(&mut self)
[src]
Clears the map, removing all elements.
pub fn to_vec(&self) -> Vec<(K, V)>
[src]
Copies elements into an std::vec::Vec
.
pub fn keys<'a>(&'a self) -> impl Iterator<Item = K> + 'a
[src]
An iterator visiting all keys. The iterator element type is K
.
pub fn values<'a>(&'a self) -> impl Iterator<Item = V> + 'a
[src]
An iterator visiting all values. The iterator element type is V
.
pub fn iter<'a>(&'a self) -> impl Iterator<Item = (K, V)> + 'a
[src]
Iterate over deserialized keys and values.
pub fn extend<IT: IntoIterator<Item = (K, V)>>(&mut self, iter: IT)
[src]
pub fn keys_as_vector(&self) -> &Vector<K>
[src]
Returns a view of keys as a vector. It's sometimes useful to have random access to the keys.
pub fn values_as_vector(&self) -> &Vector<V>
[src]
Returns a view of values as a vector. It's sometimes useful to have random access to the values.
Trait Implementations
impl<K, V> BorshDeserialize for Map<K, V> where
Vec<u8>: BorshDeserialize,
Vector<K>: BorshDeserialize,
Vector<V>: BorshDeserialize,
[src]
Vec<u8>: BorshDeserialize,
Vector<K>: BorshDeserialize,
Vector<V>: BorshDeserialize,
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
[src]
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
[src]
fn is_u8() -> bool
[src]
impl<K, V> BorshSerialize for Map<K, V> where
Vec<u8>: BorshSerialize,
Vector<K>: BorshSerialize,
Vector<V>: BorshSerialize,
[src]
Vec<u8>: BorshSerialize,
Vector<K>: BorshSerialize,
Vector<V>: BorshSerialize,
fn serialize<W: Write>(&self, writer: &mut W) -> Result<(), Error>
[src]
fn try_to_vec(&self) -> Result<Vec<u8>, Error>
[src]
fn is_u8() -> bool
[src]
impl<K, V> Default for Map<K, V>
[src]
Auto Trait Implementations
impl<K, V> RefUnwindSafe for Map<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for Map<K, V> where
K: Send,
V: Send,
K: Send,
V: Send,
impl<K, V> Sync for Map<K, V> where
K: Sync,
V: Sync,
K: Sync,
V: Sync,
impl<K, V> Unpin for Map<K, V> where
K: Unpin,
V: Unpin,
K: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for Map<K, V> where
K: UnwindSafe,
V: UnwindSafe,
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,