#[repr(align(8))]pub struct LeafNode<K, V, const PREFIX_LEN: usize> { /* private fields */ }
Expand description
Node that contains a single leaf value.
Implementations§
Source§impl<K, V, const PREFIX_LEN: usize> LeafNode<K, V, PREFIX_LEN>where
K: AsBytes,
impl<K, V, const PREFIX_LEN: usize> LeafNode<K, V, PREFIX_LEN>where
K: AsBytes,
Sourcepub unsafe fn insert_after(
this_ptr: NodePtr<PREFIX_LEN, Self>,
previous_sibling_ptr: NodePtr<PREFIX_LEN, Self>,
)
pub unsafe fn insert_after( this_ptr: NodePtr<PREFIX_LEN, Self>, previous_sibling_ptr: NodePtr<PREFIX_LEN, Self>, )
Insert the leaf node pointed to by this_ptr
into the linked list that
previous_sibling_ptr
belongs to, placing the “this” leaf node after
the “previous sibling” in the list.
§Safety
This function requires that no other operation is concurrently modifying
or reading the this_ptr
leaf node, the previous_sibling_ptr
leaf
node, and the sibling leaf node of previous_sibling_ptr
.
Sourcepub unsafe fn insert_before(
this_ptr: NodePtr<PREFIX_LEN, Self>,
next_sibling_ptr: NodePtr<PREFIX_LEN, Self>,
)
pub unsafe fn insert_before( this_ptr: NodePtr<PREFIX_LEN, Self>, next_sibling_ptr: NodePtr<PREFIX_LEN, Self>, )
Insert the leaf node pointed to by this_ptr
into the linked list that
next_sibling_ptr
belongs to, placing the “this” leaf node before
the “next sibling” in the list.
§Safety
This function requires that no other operation is concurrently modifying
or reading the this_ptr
leaf node, the next_sibling_ptr
leaf
node, and the sibling leaf node of next_sibling_ptr
.
Sourcepub unsafe fn replace(this_ptr: NodePtr<PREFIX_LEN, Self>, old_leaf: &mut Self)
pub unsafe fn replace(this_ptr: NodePtr<PREFIX_LEN, Self>, old_leaf: &mut Self)
Insert the leaf node pointed to by this_ptr
into the linked list
position that old_leaf
currently occupies, and then remove old_leaf
from the linked list.
§Safety
This function requires that no other operation is concurrently modifying
or reading the this_ptr
leaf node and the sibling leaf nodes of the
old_leaf
.
Source§impl<const PREFIX_LEN: usize, K, V> LeafNode<K, V, PREFIX_LEN>
impl<const PREFIX_LEN: usize, K, V> LeafNode<K, V, PREFIX_LEN>
Sourcepub fn with_no_siblings(key: K, value: V) -> Self
pub fn with_no_siblings(key: K, value: V) -> Self
Create a new leaf node with the given value and no siblings.
Sourcepub fn value_ref(&self) -> &V
pub fn value_ref(&self) -> &V
Returns a shared reference to the value contained by this leaf node
Sourcepub fn value_mut(&mut self) -> &mut V
pub fn value_mut(&mut self) -> &mut V
Returns a mutable reference to the value contained by this leaf node
Sourcepub fn entry_ref(&self) -> (&K, &V)
pub fn entry_ref(&self) -> (&K, &V)
Return shared references to the key and value contained by this leaf node
Sourcepub fn entry_mut(&mut self) -> (&mut K, &mut V)
pub fn entry_mut(&mut self) -> (&mut K, &mut V)
Return mutable references to the key and value contained by this leaf node
Sourcepub fn into_entry(self) -> (K, V)
pub fn into_entry(self) -> (K, V)
Consume the leaf node and return a tuple of the key and value
Sourcepub fn matches_full_key(&self, possible_key: &[u8]) -> boolwhere
K: AsBytes,
pub fn matches_full_key(&self, possible_key: &[u8]) -> boolwhere
K: AsBytes,
Check that the provided full key is the same one as the stored key.
Sourcepub unsafe fn remove_self(this_ptr: NodePtr<PREFIX_LEN, Self>)
pub unsafe fn remove_self(this_ptr: NodePtr<PREFIX_LEN, Self>)
This function removes this leaf node from its linked list.
§Safety
This function requires that no other operation is concurrently modifying
or reading the this_ptr
leaf node and its sibling leaf nodes.
Sourcepub fn clone_without_siblings(&self) -> Self
pub fn clone_without_siblings(&self) -> Self
Create a copy of this leaf node with the sibling references removed.