pub struct Node {
pub keys: Vec<Vec<u8>>,
pub vals: Vec<Vec<u8>>,
pub child_counts: Vec<u64>,
pub leaf: bool,
pub level: u8,
pub format: TreeFormat,
}Expand description
A node in the Prolly Tree
Fields§
§keys: Vec<Vec<u8>>Keys (sorted, lexicographic byte order)
vals: Vec<Vec<u8>>Values: raw bytes for leaves, CIDs for internal nodes
child_counts: Vec<u64>Logical entry counts for internal children. Empty for leaf nodes.
leaf: boolLeaf node (true) or internal node (false)
level: u8Tree level (0 = leaf level)
format: TreeFormatPersisted settings that determine tree shape and node bytes.
Implementations§
Source§impl Node
impl Node
Sourcepub fn new_internal(level: u8) -> Self
pub fn new_internal(level: u8) -> Self
Create a new internal node at the specified level
Sourcepub fn builder() -> NodeBuilder
pub fn builder() -> NodeBuilder
Create a builder for constructing a Node
Sourcepub fn search(&self, key: &[u8]) -> Result<usize, usize>
pub fn search(&self, key: &[u8]) -> Result<usize, usize>
Binary search for key index Returns Ok(index) if found, Err(index) for insertion point
Sourcepub fn min_chunk_size(&self) -> usize
pub fn min_chunk_size(&self) -> usize
Minimum size before a content boundary may be selected.
Sourcepub fn max_chunk_size(&self) -> usize
pub fn max_chunk_size(&self) -> usize
Maximum soft chunk size.
Sourcepub fn chunking_factor(&self) -> u32
pub fn chunking_factor(&self) -> u32
Compatibility accessor for threshold-based chunking.
Sourcepub fn validate(&self) -> Result<(), Error>
pub fn validate(&self) -> Result<(), Error>
Validate structural invariants independent of storage.
Sourcepub fn try_to_bytes(&self) -> Result<Vec<u8>, Error>
pub fn try_to_bytes(&self) -> Result<Vec<u8>, Error>
Serialize to deterministic bytes, returning format errors to the caller.
Sourcepub fn encoded_len(&self) -> usize
pub fn encoded_len(&self) -> usize
Return the exact length of the serialized form.
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self, Error>
pub fn from_bytes(data: &[u8]) -> Result<Self, Error>
Deserialize from current node bytes.
Sourcepub fn from_bytes_with_format(
data: &[u8],
expected: &TreeFormat,
) -> Result<Self, Error>
pub fn from_bytes_with_format( data: &[u8], expected: &TreeFormat, ) -> Result<Self, Error>
Deserialize and require an exact persisted tree format.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Node
impl<'de> Deserialize<'de> for Node
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Node
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnsafeUnpin for Node
impl UnwindSafe for Node
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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