Add the leveled extent_at/depth trait surface and the push_level context helper

This commit is contained in:
Dennis Kobert
2026-08-11 20:08:45 +00:00
parent fb94d99807
commit 557f8020bb
2 changed files with 41 additions and 0 deletions

View File

@@ -989,6 +989,21 @@ impl<'a> ContextImpl<'a> {
..*self
}
}
/// The promote half of decompose-and-promote: derives the context for the
/// content of one copy at a pushed structure level. `copy` becomes the
/// enclosing level's index (held in `frame`, which the caller owns for the
/// derived context's scope) and `inner` is the content's lane within that
/// copy. The structure node computes `copy`/`inner` from its own
/// extent-driven decomposition of the current lane.
pub fn push_level<'s>(&self, frame: &'s mut IndexLink<'s>, copy: u64, inner: u64) -> ContextImpl<'s>
where
'a: 's,
{
frame.index = copy;
frame.outer = self.index.outer;
self.promoted(frame, inner)
}
}
impl Ctx for ContextImpl<'_> {}

View File

@@ -181,6 +181,20 @@ pub trait Node<Input> {
GPoll::Final(Extent::Free)
}
/// The count of items at one absolute nesting level (innermost `0`). The
/// leveled primitive a structure node overrides to report a pushed level's
/// size; the scalar base is one item at every level. Uncertainty rides the
/// `GPoll` status axis, as with [`extent`](Node::extent).
fn extent_at(&self, _input: &Input, _level: u8) -> GPoll<Extent> {
GPoll::Final(Extent::Exactly(1))
}
/// The node's domain depth (number of nesting levels; `0` = scalar), baked
/// into the record layout at wiring.
fn depth(&self) -> u8 {
self.layout().depth
}
/// Introspection access to node-resident records; `None` for ordinary nodes.
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
None
@@ -252,6 +266,10 @@ where
(**self).extent(input)
}
fn extent_at(&self, input: &Input, level: u8) -> GPoll<Extent> {
(**self).extent_at(input, level)
}
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
(**self).serialize()
}
@@ -282,6 +300,10 @@ where
(**self).extent(input)
}
fn extent_at(&self, input: &Input, level: u8) -> GPoll<Extent> {
(**self).extent_at(input, level)
}
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
(**self).serialize()
}
@@ -312,6 +334,10 @@ where
(**self).extent(input)
}
fn extent_at(&self, input: &Input, level: u8) -> GPoll<Extent> {
(**self).extent_at(input, level)
}
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
(**self).serialize()
}