pub enum ArtNode {
Node4 {
prefix: Vec<u8>,
keys: [u8; 4],
children: [Option<Box<ArtNode>>; 4],
offsets: Vec<u64>,
overflow_offsets: Vec<u64>,
count: u16,
},
Node16 {
prefix: Vec<u8>,
keys: [u8; 16],
children: [Option<Box<ArtNode>>; 16],
offsets: Vec<u64>,
overflow_offsets: Vec<u64>,
count: u16,
},
Node48 {
prefix: Vec<u8>,
child_index: [u8; 256],
children: Box<[Option<Box<ArtNode>>; 48]>,
offsets: Vec<u64>,
overflow_offsets: Vec<u64>,
count: u16,
},
Node256 {
prefix: Vec<u8>,
children: Box<[Option<Box<ArtNode>>; 256]>,
offsets: Vec<u64>,
overflow_offsets: Vec<u64>,
count: u16,
},
}Expand description
An ART node — stores a prefix, child pointers, and value offsets.
Uses a flat enum to model the four growth stages. Each variant stores a fixed-size array of children (or indirect index + compact array).
Variants§
Implementations§
Source§impl ArtNode
impl ArtNode
Sourcepub fn prefix_mut(&mut self) -> &mut Vec<u8> ⓘ
pub fn prefix_mut(&mut self) -> &mut Vec<u8> ⓘ
Get the prefix bytes (mutable).
Sourcepub fn has_offsets(&self) -> bool
pub fn has_offsets(&self) -> bool
Returns true if this node has any offsets (i.e., it’s a leaf or contains leaves).
Sourcepub fn all_offsets(&self) -> Vec<u64>
pub fn all_offsets(&self) -> Vec<u64>
Get all offsets (primary + overflow) as a slice.
Sourcepub fn insert_child(&mut self, byte: u8, child: Box<ArtNode>)
pub fn insert_child(&mut self, byte: u8, child: Box<ArtNode>)
Insert a child at the given byte. Grows the node if necessary.
Sourcepub fn get_child_mut(&mut self, byte: u8) -> Option<&mut Box<ArtNode>>
pub fn get_child_mut(&mut self, byte: u8) -> Option<&mut Box<ArtNode>>
Get a mutable child by byte, if it exists.
Sourcepub fn get_or_insert_child(&mut self, byte: u8) -> &mut Box<ArtNode>
pub fn get_or_insert_child(&mut self, byte: u8) -> &mut Box<ArtNode>
Get or insert a child node at the given byte. Returns a mutable reference to the child, creating a new empty Node4 if needed.
Sourcepub fn remove_child(&mut self, byte: u8)
pub fn remove_child(&mut self, byte: u8)
Remove a child by byte. Does not shrink the node.
Sourcepub fn add_offset(&mut self, offset: u64)
pub fn add_offset(&mut self, offset: u64)
Add a value offset to this node.
Sourcepub fn remove_offset(&mut self, offset: u64) -> bool
pub fn remove_offset(&mut self, offset: u64) -> bool
Remove a specific offset from this node’s offsets or overflow.
Returns true if the offset was found and removed.
Sourcepub fn clear_offsets(&mut self)
pub fn clear_offsets(&mut self)
Clear all offsets from this node.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ArtNode
impl RefUnwindSafe for ArtNode
impl Send for ArtNode
impl Sync for ArtNode
impl Unpin for ArtNode
impl UnsafeUnpin for ArtNode
impl UnwindSafe for ArtNode
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more