Skip to main content

Node

Enum Node 

Source
pub enum Node {
    Leaf(Box<LeafNode>),
    Internal(Box<InternalNode>),
}
Expand description

In-memory CHK node — either a leaf with key/value entries or an internal node referencing other nodes. Mirrors the Python Node base class hierarchy (LeafNode | InternalNode).

Variants§

§

Leaf(Box<LeafNode>)

§

Internal(Box<InternalNode>)

Implementations§

Source§

impl Node

Source

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

(b"sha1:...",) key once the node has been serialised, else None. Mirrors Python’s Node.key().

Source

pub fn len(&self) -> usize

Total number of leaf entries reachable through this node. Mirrors Python’s Node.__len__.

Source

pub fn maximum_size(&self) -> usize

Maximum byte size allowed for this node when serialised, or 0 for unlimited.

Source

pub fn refs(&self) -> Result<Vec<Vec<u8>>, Error>

CHK references held by this node. Mirrors Node.refs: leaves never reference other pages (returns []); internal nodes return their children’s sha1 keys (delegates to InternalNode::refs, which requires the node to have been serialised).

Source

pub fn map( &mut self, key: Vec<Vec<u8>>, value: Vec<u8>, ) -> Result<MapResult, Error>

Insert (key, value) into this subtree (pure in-memory path).

For leaves, delegates to LeafNode::map. For internal nodes, returns AssertionFailed — the recursive InternalNode path needs the store and lives at Node::map_with_store. This signature exists so LeafNode::split (which only ever creates fresh in-memory sub-leaves) can recurse via Node::map without a store argument.

Source

pub fn serialise<S>( &mut self, store: &S, cache: &dyn PageCache, ) -> Result<Vec<Vec<u8>>, Error>
where S: VersionedFiles + ?Sized,

Serialise this subtree to the store, returning every sha1 key written (children first, then self). Mirrors Python’s Node.serialise. Skips children that are unloaded (their sha1 key is already canonical) or already serialised (key set).

Source

pub fn unmap_with_store<S>( self, store: &S, cache: &dyn PageCache, key: &[Vec<u8>], check_remap: bool, ) -> Result<Node, Error>
where S: VersionedFiles + ?Sized,

Recursive remove that may demand-load child pages. Returns the replacement node (possibly the same one, possibly a collapsed leaf, possibly the single remaining child if the internal node lost all but one child).

Mirrors Python’s polymorphic unmap(store, key, check_remap). Raises KeyError-equivalent (AssertionFailed) when the key is not present.

Source

pub fn map_with_store<S>( &mut self, store: &S, cache: &dyn PageCache, key: Vec<Vec<u8>>, value: Vec<u8>, ) -> Result<MapResult, Error>
where S: VersionedFiles + ?Sized,

Recursive insert that may demand-load child pages from the store. Mirrors Python’s polymorphic dispatch: LeafNode.map(store, key, value) for leaves; InternalNode.map(store, key, value) for internal nodes (which descends into the matching child, possibly creating a new wrapping parent if the key falls outside the current search prefix).

May replace *self with a new node (e.g. an internal node promoting itself into a larger parent, or a parent collapsing back into a leaf after _check_remap).

Source

pub fn iteritems<S>( &mut self, store: &S, cache: &dyn PageCache, key_filter: Option<&[Vec<Vec<u8>>]>, ) -> Result<Vec<(Vec<Vec<u8>>, Vec<u8>)>, Error>
where S: VersionedFiles + ?Sized,

Iterate (key, value) pairs in this subtree matching key_filter. Mirrors Python’s polymorphic iteritems: leaves yield directly; internal nodes recurse through iter_nodes, demand-loading children as needed.

Trait Implementations§

Source§

impl Clone for Node

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Node

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Node

§

impl !UnwindSafe for Node

§

impl Freeze for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnsafeUnpin for Node

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> Ungil for T
where T: Send,