Struct dharitri_wasm::storage::mappers::MapStorageMapper
source · pub struct MapStorageMapper<SA, K, V>where
SA: StorageReadApi + StorageWriteApi + ErrorApi + Clone + 'static,
K: TopEncode + TopDecode + 'static,
V: StorageMapper<SA> + StorageClearable,{ /* private fields */ }Implementations§
source§impl<SA, K, V> MapStorageMapper<SA, K, V>where
SA: StorageReadApi + StorageWriteApi + ErrorApi + Clone + 'static,
K: TopEncode + TopDecode,
V: StorageMapper<SA> + StorageClearable,
impl<SA, K, V> MapStorageMapper<SA, K, V>where
SA: StorageReadApi + StorageWriteApi + ErrorApi + Clone + 'static,
K: TopEncode + TopDecode,
V: StorageMapper<SA> + StorageClearable,
sourcepub fn contains_key(&self, k: &K) -> bool
pub fn contains_key(&self, k: &K) -> bool
Returns true if the map contains a value for the specified key.
sourcepub fn insert_default(&mut self, k: K) -> bool
pub fn insert_default(&mut self, k: K) -> bool
Adds a default value for the key, if it is not already present.
If the map did not have this key present, true is returned.
If the map did have this value present, false is returned.
sourcepub fn get_or_insert_default(&mut self, k: K) -> V
pub fn get_or_insert_default(&mut self, k: K) -> V
Returns the value corresponding to the key.
If the key is not found, it is inserted and a new default value is returned.
sourcepub fn keys(&self) -> Iter<'_, SA, K>
pub fn keys(&self) -> Iter<'_, SA, K>
An iterator visiting all keys in arbitrary order.
The iterator element type is &'a K.
Trait Implementations§
source§impl<SA, K, V> StorageClearable for MapStorageMapper<SA, K, V>where
SA: StorageReadApi + StorageWriteApi + ErrorApi + Clone + 'static,
K: TopEncode + TopDecode,
V: StorageMapper<SA> + StorageClearable,
impl<SA, K, V> StorageClearable for MapStorageMapper<SA, K, V>where
SA: StorageReadApi + StorageWriteApi + ErrorApi + Clone + 'static,
K: TopEncode + TopDecode,
V: StorageMapper<SA> + StorageClearable,
source§impl<SA, K, V> StorageMapper<SA> for MapStorageMapper<SA, K, V>where
SA: StorageReadApi + StorageWriteApi + ErrorApi + Clone + 'static,
K: TopEncode + TopDecode,
V: StorageMapper<SA> + StorageClearable,
impl<SA, K, V> StorageMapper<SA> for MapStorageMapper<SA, K, V>where
SA: StorageReadApi + StorageWriteApi + ErrorApi + Clone + 'static,
K: TopEncode + TopDecode,
V: StorageMapper<SA> + StorageClearable,
source§fn new(api: SA, main_key: BoxedBytes) -> Self
fn new(api: SA, main_key: BoxedBytes) -> Self
Will be called automatically by the
#[storage_mapper] annotation generated code.Auto Trait Implementations§
impl<SA, K, V> RefUnwindSafe for MapStorageMapper<SA, K, V>
impl<SA, K, V> Send for MapStorageMapper<SA, K, V>
impl<SA, K, V> Sync for MapStorageMapper<SA, K, V>
impl<SA, K, V> Unpin for MapStorageMapper<SA, K, V>
impl<SA, K, V> UnwindSafe for MapStorageMapper<SA, K, V>
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