Skip to main content

OccupiedEntry

Struct OccupiedEntry 

Source
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>,

Source

pub const fn key(&self) -> &[u8]

Gets a reference to the key in the entry.

Source

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.

Source

pub fn into_value(self) -> P::Output

Converts the OccupiedEntry into the value

Source

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 returned
  • None - Key was deleted concurrently, new value inserted anyway
Source

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.

Source

pub fn try_remove(self) -> Result<Option<P::Output>, RemoveError>

Fallible version of remove

§Errors

Returns error if removal failed

Source

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.

Source

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.

Trait Implementations§

Source§

impl<P, A> Debug for OccupiedEntry<'_, '_, P, A>
where P: LeafPolicy, P::Output: Send + Sync + Debug, A: TreeAllocator<P>,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'t, 'e, P, A> Freeze for OccupiedEntry<'t, 'e, P, A>
where <P as LeafPolicy>::Output: Freeze,

§

impl<'t, 'e, P, A> !RefUnwindSafe for OccupiedEntry<'t, 'e, P, A>

§

impl<'t, 'e, P, A> !Send for OccupiedEntry<'t, 'e, P, A>

§

impl<'t, 'e, P, A> !Sync for OccupiedEntry<'t, 'e, P, A>

§

impl<'t, 'e, P, A> Unpin for OccupiedEntry<'t, 'e, P, A>
where <P as LeafPolicy>::Output: Unpin,

§

impl<'t, 'e, P, A> !UnwindSafe for OccupiedEntry<'t, 'e, P, A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.