pub struct OccupiedEntry<'t, 'e, P, A>where
P: LeafPolicy,
A: TreeAllocator<P>,{ /* private fields */ }Expand description
A view into an occupied entry in a tree.
Created by Entry::Occupied variant from
entry_with_guard.
NOTE: The “occupied” status was determined at entry creation time.
Under concurrency, the key may have been deleted since then. Methods
handle this gracefully by returning Option or Result.
Implementations§
Source§impl<P, A> OccupiedEntry<'_, '_, P, A>where
P: LeafPolicy,
A: TreeAllocator<P>,
impl<P, A> OccupiedEntry<'_, '_, P, A>where
P: LeafPolicy,
A: TreeAllocator<P>,
Sourcepub const fn get(&self) -> &P::Output
pub const fn get(&self) -> &P::Output
Gets a reference to the value in the entry.
NOTE: This is the value at entry creation time (or last modification via this entry). If another thread has modified the key since then, this may be stale.
Sourcepub fn into_value(self) -> P::Output
pub fn into_value(self) -> P::Output
Converts the OccupiedEntry into the value
Sourcepub fn insert(&mut self, value: P::Value) -> Option<P::Output>
pub fn insert(&mut self, value: P::Value) -> Option<P::Output>
Sets the value of the entry, and returns the old value.
§Returns
Some(old)- Key existed, old value returnedNone- Key was deleted concurrently, new value inserted anyway
Sourcepub fn remove(self) -> Option<P::Output>
pub fn remove(self) -> Option<P::Output>
Removes the entry from the tree and returns the actually removed value.
Unlike some Entry implementations, this returns the value that was actually in the tree at removal time, not a stale snapshot.
§Panics
Panics if removal fails (extremely rare - only on retry limit exceeded).
Use try_remove for fallible operation.
Sourcepub fn try_remove(self) -> Result<Option<P::Output>, RemoveError>
pub fn try_remove(self) -> Result<Option<P::Output>, RemoveError>
Sourcepub fn remove_entry(self) -> Option<(Vec<u8>, P::Output)>
pub fn remove_entry(self) -> Option<(Vec<u8>, P::Output)>
Removes the entry from the tree and returns the key and removed value.
NOTE: Returns the key as a Vec<u8> copy since the Entry borrows the key.
§Panics
Panics if removal fails. Use try_remove_entry
for fallible operation.
Sourcepub fn try_remove_entry(
self,
) -> Result<Option<(Vec<u8>, P::Output)>, RemoveError>
pub fn try_remove_entry( self, ) -> Result<Option<(Vec<u8>, P::Output)>, RemoveError>
Fallible version of remove_entry.
§Errors
Returns an error if the underlying tree operation encounters a failure.