pub enum Entry<'a, K: Key + 'static, V: Value + 'static> {
Occupied(OccupiedEntry<'a, K, V>),
Vacant(VacantEntry<'a, K, V>),
}Expand description
A view into a single entry in a Table, which may either be vacant or occupied.
This enum is constructed from the entry method on Table, and mirrors
std::collections::btree_map::Entry as closely as the redb data model allows.
Unlike the in-memory BTreeMap, redb values are stored serialized, so methods that
produce a “reference to the value” return an AccessGuardMut instead of &mut V.
Variants§
Implementations§
Source§impl<'a, K: Key + 'static, V: Value + 'static> Entry<'a, K, V>
impl<'a, K: Key + 'static, V: Value + 'static> Entry<'a, K, V>
Sourcepub fn or_insert<'v>(
self,
default: impl Borrow<V::SelfType<'v>>,
) -> Result<AccessGuardMut<'a, V>>
pub fn or_insert<'v>( self, default: impl Borrow<V::SelfType<'v>>, ) -> Result<AccessGuardMut<'a, V>>
Ensures a value is in the entry by inserting the provided default if empty,
and returns a mutable accessor to the value in the entry.
Sourcepub fn or_insert_with<'v, F, B>(
self,
default: F,
) -> Result<AccessGuardMut<'a, V>>
pub fn or_insert_with<'v, F, B>( self, default: F, ) -> Result<AccessGuardMut<'a, V>>
Ensures a value is in the entry by inserting the result of default if empty,
and returns a mutable accessor to the value in the entry.
Unlike or_insert, the default value is only computed if the
entry is vacant.
Sourcepub fn or_insert_with_key<'v, F, B>(
self,
default: F,
) -> Result<AccessGuardMut<'a, V>>
pub fn or_insert_with_key<'v, F, B>( self, default: F, ) -> Result<AccessGuardMut<'a, V>>
Ensures a value is in the entry by inserting, if empty, the result of the default
function, which is given a view of the key.
Sourcepub fn and_modify<F>(self, f: F) -> Result<Self>
pub fn and_modify<F>(self, f: F) -> Result<Self>
Provides in-place mutable access to an occupied entry before any potential inserts into the table.
The closure receives an AccessGuardMut and may replace the stored value via
AccessGuardMut::insert. Any errors returned by the closure are propagated.