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>where
K: 'a,
KR: Borrow<K::SelfType<'a>> + 'a,
pub fn drain<'a, KR>( &mut self, range: impl RangeBounds<KR> + 'a ) -> Result<Drain<'_, K, V>, StorageError>where K: 'a, KR: Borrow<K::SelfType<'a>> + 'a,
Removes the specified range and returns the removed entries in an iterator
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>where
K: 'a,
KR: Borrow<K::SelfType<'a>> + 'a,
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>where K: 'a, KR: Borrow<K::SelfType<'a>> + 'a,
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
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: RedbValueMutInPlace + 'static> Table<'db, 'txn, K, V>
impl<'db, 'txn, K: RedbKey + 'static, V: RedbValueMutInPlace + '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
Trait Implementations§
source§impl<'db, 'txn, K: RedbKey + 'static, V: RedbValue + 'static> Drop for Table<'db, 'txn, K, V>
impl<'db, 'txn, K: RedbKey + 'static, V: RedbValue + 'static> Drop for Table<'db, 'txn, K, V>
source§impl<'db, 'txn, K: RedbKey + 'static, V: RedbValue + 'static> ReadableTable<K, V> for Table<'db, 'txn, K, V>
impl<'db, 'txn, K: RedbKey + 'static, V: RedbValue + 'static> ReadableTable<K, V> for Table<'db, 'txn, K, V>
source§fn get<'a>(
&self,
key: impl Borrow<K::SelfType<'a>>
) -> Result<Option<AccessGuard<'_, V>>, StorageError>where
K: 'a,
fn get<'a>( &self, key: impl Borrow<K::SelfType<'a>> ) -> Result<Option<AccessGuard<'_, V>>, StorageError>where K: 'a,
Returns the value corresponding to the given key
source§fn range<'a, KR>(
&self,
range: impl RangeBounds<KR> + 'a
) -> Result<Range<'_, K, V>, StorageError>where
K: 'a,
KR: Borrow<K::SelfType<'a>> + 'a,
fn range<'a, KR>( &self, range: impl RangeBounds<KR> + 'a ) -> Result<Range<'_, K, V>, StorageError>where K: 'a, KR: Borrow<K::SelfType<'a>> + 'a,
Returns a double-ended iterator over a range of elements in the table Read more
Auto Trait Implementations§
impl<'db, 'txn, K, V> RefUnwindSafe for Table<'db, 'txn, K, V>where K: RefUnwindSafe, V: RefUnwindSafe,
impl<'db, 'txn, K, V> Send for Table<'db, 'txn, K, V>where K: Send, V: Send,
impl<'db, 'txn, K, V> Sync for Table<'db, 'txn, K, V>where K: Sync, V: Sync,
impl<'db, 'txn, K, V> Unpin for Table<'db, 'txn, K, V>where K: Unpin, V: Unpin,
impl<'db, 'txn, K, V> UnwindSafe for Table<'db, 'txn, K, V>where K: UnwindSafe, V: UnwindSafe,
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