pub struct Table<'db, 'txn, K: RedbKey + 'static, V: RedbValue + 'static> { /* private fields */ }
Expand description
A table containing key-value mappings
Implementations§
Source§impl<'db, 'txn, K: RedbKey + 'static, V: RedbValue + 'static> Table<'db, 'txn, K, V>
impl<'db, 'txn, K: RedbKey + 'static, V: RedbValue + 'static> Table<'db, '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 drain<'a, KR>(
&mut self,
range: impl RangeBounds<KR> + 'a,
) -> Result<Drain<'_, K, V>, StorageError>
pub fn drain<'a, KR>( &mut self, range: impl RangeBounds<KR> + 'a, ) -> Result<Drain<'_, K, V>, StorageError>
Removes the specified range and returns the removed entries in an iterator
The iterator will consume all items in the range on drop.
Sourcepub fn drain_filter<'a, KR, F: for<'f> Fn(K::SelfType<'f>, V::SelfType<'f>) -> bool>(
&mut self,
range: impl RangeBounds<KR> + 'a,
predicate: F,
) -> Result<DrainFilter<'_, K, V, F>, StorageError>
pub fn drain_filter<'a, KR, F: for<'f> Fn(K::SelfType<'f>, V::SelfType<'f>) -> bool>( &mut self, range: impl RangeBounds<KR> + 'a, predicate: F, ) -> Result<DrainFilter<'_, K, V, F>, StorageError>
Applies predicate
to all key-value pairs in the specified range. All entries for which
predicate
evaluates to true
are removed and returned in an iterator
The iterator will consume all items in the range matching the predicate on drop.
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>where
K: 'a,
pub fn remove<'a>(
&mut self,
key: impl Borrow<K::SelfType<'a>>,
) -> Result<Option<AccessGuard<'_, V>>, StorageError>where
K: 'a,
Removes the given key
Returns the old value, if the key was present in the table
Source§impl<'db, 'txn, K: RedbKey + 'static, V: MutInPlaceValue + 'static> Table<'db, 'txn, K, V>
impl<'db, 'txn, K: RedbKey + 'static, V: MutInPlaceValue + 'static> Table<'db, 'txn, K, V>
Sourcepub fn insert_reserve<'a>(
&mut self,
key: impl Borrow<K::SelfType<'a>>,
value_length: u32,
) -> Result<AccessGuardMut<'_, V>, StorageError>where
K: 'a,
pub fn insert_reserve<'a>(
&mut self,
key: impl Borrow<K::SelfType<'a>>,
value_length: u32,
) -> Result<AccessGuardMut<'_, V>, StorageError>where
K: 'a,
Reserve space to insert a key-value pair The returned reference will have length equal to value_length