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>)>, Error>
pub fn pop_first(
&mut self
) -> Result<Option<(AccessGuard<'_, K>, AccessGuard<'_, V>)>, Error>
Removes and returns the first key-value pair in the table
sourcepub fn pop_last(
&mut self
) -> Result<Option<(AccessGuard<'_, K>, AccessGuard<'_, V>)>, Error>
pub fn pop_last(
&mut self
) -> Result<Option<(AccessGuard<'_, K>, AccessGuard<'_, V>)>, Error>
Removes and returns the last key-value pair in the table
sourcepub fn drain<'a: 'b, 'b, KR>(
&'a mut self,
range: impl RangeBounds<KR> + Clone + 'b
) -> Result<Drain<'a, K, V>, Error>where
K: 'a,
KR: Borrow<K::SelfType<'b>> + Clone + 'b,
pub fn drain<'a: 'b, 'b, KR>(
&'a mut self,
range: impl RangeBounds<KR> + Clone + 'b
) -> Result<Drain<'a, K, V>, Error>where
K: 'a,
KR: Borrow<K::SelfType<'b>> + Clone + 'b,
Removes the specified range and returns the removed entries in an iterator
sourcepub fn drain_filter<'a: 'b, 'b, KR, F: for<'f> Fn(K::SelfType<'f>, V::SelfType<'f>) -> bool>(
&'a mut self,
range: impl RangeBounds<KR> + Clone + 'b,
predicate: F
) -> Result<DrainFilter<'a, K, V, F>, Error>where
K: 'a,
KR: Borrow<K::SelfType<'b>> + Clone + 'b,
pub fn drain_filter<'a: 'b, 'b, KR, F: for<'f> Fn(K::SelfType<'f>, V::SelfType<'f>) -> bool>(
&'a mut self,
range: impl RangeBounds<KR> + Clone + 'b,
predicate: F
) -> Result<DrainFilter<'a, K, V, F>, Error>where
K: 'a,
KR: Borrow<K::SelfType<'b>> + Clone + 'b,
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<'a>(
&mut self,
key: impl Borrow<K::SelfType<'a>>,
value: impl Borrow<V::SelfType<'a>>
) -> Result<Option<AccessGuard<'_, V>>, Error>where
K: 'a,
V: 'a,
pub fn insert<'a>(
&mut self,
key: impl Borrow<K::SelfType<'a>>,
value: impl Borrow<V::SelfType<'a>>
) -> Result<Option<AccessGuard<'_, V>>, Error>where
K: 'a,
V: 'a,
Insert mapping of the given key to the given value
Returns the old value, if the key was present in the table
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>>, Error>where
K: 'a,
fn get<'a>(
&self,
key: impl Borrow<K::SelfType<'a>>
) -> Result<Option<AccessGuard<'_, V>>, Error>where
K: 'a,
Returns the value corresponding to the given key