pub struct Table<'txn, K: Key + 'static, V: Value + 'static> { /* private fields */ }
Expand description
A table containing key-value mappings
Implementations§
source§impl<'txn, K: Key + 'static, V: Value + 'static> Table<'txn, K, V>
impl<'txn, K: Key + 'static, V: Value + 'static> Table<'txn, K, V>
sourcepub fn pop_first(
&mut self
) -> Result<Option<(AccessGuard<'_, K>, AccessGuard<'_, V>)>, StorageError>
pub fn pop_first( &mut self ) -> Result<Option<(AccessGuard<'_, K>, AccessGuard<'_, V>)>, StorageError>
Removes and returns the first key-value pair in the table
sourcepub fn pop_last(
&mut self
) -> Result<Option<(AccessGuard<'_, K>, AccessGuard<'_, V>)>, StorageError>
pub fn pop_last( &mut self ) -> Result<Option<(AccessGuard<'_, K>, AccessGuard<'_, V>)>, StorageError>
Removes and returns the last key-value pair in the table
sourcepub fn extract_if<F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool>(
&mut self,
predicate: F
) -> Result<ExtractIf<'_, K, V, F>, StorageError>
pub fn extract_if<F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool>( &mut self, predicate: F ) -> Result<ExtractIf<'_, K, V, F>, StorageError>
Applies predicate
to all key-value pairs. All entries for which
predicate
evaluates to true
are returned in an iterator, and those which are read from the iterator are removed
Note: values not read from the iterator will not be removed
sourcepub fn extract_from_if<'a, KR, F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool>(
&mut self,
range: impl RangeBounds<KR> + 'a,
predicate: F
) -> Result<ExtractIf<'_, K, V, F>, StorageError>
pub fn extract_from_if<'a, KR, F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool>( &mut self, range: impl RangeBounds<KR> + 'a, predicate: F ) -> Result<ExtractIf<'_, K, V, F>, StorageError>
Applies predicate
to all key-value pairs in the specified range. All entries for which
predicate
evaluates to true
are returned in an iterator, and those which are read from the iterator are removed
Note: values not read from the iterator will not be removed
sourcepub fn retain<F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool>(
&mut self,
predicate: F
) -> Result<(), StorageError>
pub fn retain<F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool>( &mut self, predicate: F ) -> Result<(), StorageError>
Applies predicate
to all key-value pairs. All entries for which
predicate
evaluates to false
are removed.
sourcepub fn retain_in<'a, KR, F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool>(
&mut self,
range: impl RangeBounds<KR> + 'a,
predicate: F
) -> Result<(), StorageError>
pub fn retain_in<'a, KR, F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool>( &mut self, range: impl RangeBounds<KR> + 'a, predicate: F ) -> Result<(), StorageError>
Applies predicate
to all key-value pairs in the range start..end
. All entries for which
predicate
evaluates to false
are removed.
sourcepub fn insert<'k, 'v>(
&mut self,
key: impl Borrow<K::SelfType<'k>>,
value: impl Borrow<V::SelfType<'v>>
) -> Result<Option<AccessGuard<'_, V>>, StorageError>
pub fn insert<'k, 'v>( &mut self, key: impl Borrow<K::SelfType<'k>>, value: impl Borrow<V::SelfType<'v>> ) -> Result<Option<AccessGuard<'_, V>>, StorageError>
Insert mapping of the given key to the given value
Returns the old value, if the key was present in the table
sourcepub fn remove<'a>(
&mut self,
key: impl Borrow<K::SelfType<'a>>
) -> Result<Option<AccessGuard<'_, V>>, StorageError>
pub fn remove<'a>( &mut self, key: impl Borrow<K::SelfType<'a>> ) -> Result<Option<AccessGuard<'_, V>>, StorageError>
Removes the given key
Returns the old value, if the key was present in the table
source§impl<'txn, K: Key + 'static, V: MutInPlaceValue + 'static> Table<'txn, K, V>
impl<'txn, K: Key + 'static, V: MutInPlaceValue + 'static> Table<'txn, K, V>
sourcepub fn insert_reserve<'a>(
&mut self,
key: impl Borrow<K::SelfType<'a>>,
value_length: u32
) -> Result<AccessGuardMut<'_, V>, StorageError>
pub fn insert_reserve<'a>( &mut self, key: impl Borrow<K::SelfType<'a>>, value_length: u32 ) -> Result<AccessGuardMut<'_, V>, StorageError>
Reserve space to insert a key-value pair The returned reference will have length equal to value_length