pub struct CascadeResolverN<T: Copy + Default + 'static, const DEPTH: usize> {
pub intermediate: Vec<SharedRegion<u32>>,
pub leaf: SharedRegion<T>,
/* private fields */
}Expand description
Generic N-level resolver: caller provides a sequence of SharedRegions, one per non-leaf level holding intermediate cascade pointers, plus the leaf region holding T. Resolution walks the indices array level-by-level.
This is the explicit-walk variant. For a more ergonomic 4-level MMU-shaped resolver, callers can wrap this in their own type.
Fields§
§intermediate: Vec<SharedRegion<u32>>Intermediate regions, one per non-leaf level. Each holds a flat u32 (the next level’s index). For depth N, this has length N-1.
leaf: SharedRegion<T>Leaf region holding T.
Implementations§
Source§impl<T: Copy + Default + 'static, const DEPTH: usize> CascadeResolverN<T, DEPTH>
impl<T: Copy + Default + 'static, const DEPTH: usize> CascadeResolverN<T, DEPTH>
pub fn create( leaf_path: impl AsRef<Path>, leaf_capacity: usize, intermediate_paths_and_caps: Vec<(PathBuf, usize)>, ) -> Result<Self, CascadeError>
pub fn open( leaf_path: impl AsRef<Path>, leaf_capacity: usize, intermediate_paths_and_caps: Vec<(PathBuf, usize)>, ) -> Result<Self, CascadeError>
Sourcepub fn allocate_leaf(&self, value: T) -> Result<u32, CascadeError>
pub fn allocate_leaf(&self, value: T) -> Result<u32, CascadeError>
Allocate a T value at the leaf and return its cascade. The caller is responsible for populating the intermediate levels (e.g., by treating outer indices as slot positions that reference the next-level slot to descend into).
For the simplest case where each level’s “index” is just the
slot position in the corresponding intermediate region, use
insert_path which performs the full descent.
Sourcepub fn insert_at_top(
&self,
top_idx: u32,
value: T,
) -> Result<KTowerCascade<T, DEPTH>, CascadeError>
pub fn insert_at_top( &self, top_idx: u32, value: T, ) -> Result<KTowerCascade<T, DEPTH>, CascadeError>
Insert at a chosen TOP-LEVEL slot. Every intermediate level
and the leaf are auto-allocated to fresh slots. Returns the
full cascade. Calling twice with the same top_idx will
OVERWRITE the previous top-level chain (the orphaned
intermediates remain in their regions but become unreachable
from top_idx).
For independent insertions, use distinct top_idx values
(typically cascade_count, i.e. the next free top slot,
which can be obtained as intermediate[0].len() as u32).
Sourcepub fn append(&self, value: T) -> Result<KTowerCascade<T, DEPTH>, CascadeError>
pub fn append(&self, value: T) -> Result<KTowerCascade<T, DEPTH>, CascadeError>
Append a fresh entry. Picks the next free top slot
automatically. Equivalent to
insert_at_top(intermediate[0].len() as u32, value) for
DEPTH > 1, or (allocate leaf, return its index) for DEPTH=1.
Sourcepub fn get(&self, c: KTowerCascade<T, DEPTH>) -> Result<T, CascadeError>
pub fn get(&self, c: KTowerCascade<T, DEPTH>) -> Result<T, CascadeError>
Resolve a cascade to its T value by walking the levels.