Struct near_sdk::collections::LookupMap[][src]

pub struct LookupMap<K, V> { /* fields omitted */ }

An non-iterable implementation of a map that stores its content directly on the trie.

Implementations

impl<K, V> LookupMap<K, V>[src]

pub fn new(key_prefix: Vec<u8>) -> Self[src]

Create a new map. Use key_prefix as a unique prefix for keys.

pub fn insert_raw(
    &mut self,
    key_raw: &[u8],
    value_raw: &[u8]
) -> Option<Vec<u8>>
[src]

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> LookupMap<K, V> where
    K: BorshSerialize,
    V: BorshSerialize + BorshDeserialize
[src]

pub fn contains_key(&self, key: &K) -> bool[src]

Returns true if the map contains a given key.

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 extend<IT: IntoIterator<Item = (K, V)>>(&mut self, iter: IT)[src]

Trait Implementations

impl<K, V> BorshDeserialize for LookupMap<K, V> where
    Vec<u8>: BorshDeserialize
[src]

impl<K, V> BorshSerialize for LookupMap<K, V> where
    Vec<u8>: BorshSerialize
[src]

Auto Trait Implementations

impl<K, V> RefUnwindSafe for LookupMap<K, V> where
    K: RefUnwindSafe,
    V: RefUnwindSafe

impl<K, V> Send for LookupMap<K, V> where
    K: Send,
    V: Send

impl<K, V> Sync for LookupMap<K, V> where
    K: Sync,
    V: Sync

impl<K, V> Unpin for LookupMap<K, V> where
    K: Unpin,
    V: Unpin

impl<K, V> UnwindSafe for LookupMap<K, V> where
    K: UnwindSafe,
    V: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.