Struct LeafNode

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

Source

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.

Source

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.

Source

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>

Source

pub fn with_no_siblings(key: K, value: V) -> Self

Create a new leaf node with the given value and no siblings.

Source

pub fn key_ref(&self) -> &K

Returns a shared reference to the key contained by this leaf node

Source

pub fn value_ref(&self) -> &V

Returns a shared reference to the value contained by this leaf node

Source

pub fn value_mut(&mut self) -> &mut V

Returns a mutable reference to the value contained by this leaf node

Source

pub fn entry_ref(&self) -> (&K, &V)

Return shared references to the key and value contained by this leaf node

Source

pub fn entry_mut(&mut self) -> (&mut K, &mut V)

Return mutable references to the key and value contained by this leaf node

Source

pub fn into_entry(self) -> (K, V)

Consume the leaf node and return a tuple of the key and value

Source

pub fn matches_full_key(&self, possible_key: &[u8]) -> bool
where K: AsBytes,

Check that the provided full key is the same one as the stored key.

Source

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.

Source

pub fn clone_without_siblings(&self) -> Self
where K: Clone, V: Clone,

Create a copy of this leaf node with the sibling references removed.

Trait Implementations§

Source§

impl<K: Debug, V: Debug, const PREFIX_LEN: usize> Debug for LeafNode<K, V, PREFIX_LEN>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<const PREFIX_LEN: usize, K, V> Node<PREFIX_LEN> for LeafNode<K, V, PREFIX_LEN>

Source§

const TYPE: NodeType = NodeType::Leaf

The runtime type of the node.
Source§

type Key = K

The key type carried by the leaf nodes
Source§

type Value = V

The value type carried by the leaf nodes
Source§

impl<K, T, const PREFIX_LEN: usize> Visitable<K, T, PREFIX_LEN> for LeafNode<K, T, PREFIX_LEN>

Source§

fn super_visit_with<V: Visitor<K, T, PREFIX_LEN>>( &self, visitor: &mut V, ) -> V::Output

This function provides the default traversal behavior for the implementing type. Read more
Source§

fn visit_with<V: Visitor<K, T, PREFIX_LEN>>(&self, visitor: &mut V) -> V::Output

This function will traverse the implementing type and execute any specific logic from the given Visitor. Read more

Auto Trait Implementations§

§

impl<K, V, const PREFIX_LEN: usize> Freeze for LeafNode<K, V, PREFIX_LEN>
where V: Freeze, K: Freeze,

§

impl<K, V, const PREFIX_LEN: usize> RefUnwindSafe for LeafNode<K, V, PREFIX_LEN>

§

impl<K, V, const PREFIX_LEN: usize> !Send for LeafNode<K, V, PREFIX_LEN>

§

impl<K, V, const PREFIX_LEN: usize> !Sync for LeafNode<K, V, PREFIX_LEN>

§

impl<K, V, const PREFIX_LEN: usize> Unpin for LeafNode<K, V, PREFIX_LEN>
where V: Unpin, K: Unpin,

§

impl<K, V, const PREFIX_LEN: usize> UnwindSafe for LeafNode<K, V, PREFIX_LEN>

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.