pub struct NodeStore { /* private fields */ }Expand description
The single owner of every node, table row, child list, string, and resource.
Implementations§
Source§impl NodeStore
impl NodeStore
Sourcepub fn publish_table_views(
&self,
changes: &ChangeSet,
out: &mut Vec<NvTableView>,
owners_buf: &mut Vec<NodeId>,
)
pub fn publish_table_views( &self, changes: &ChangeSet, out: &mut Vec<NvTableView>, owners_buf: &mut Vec<NodeId>, )
Populates out with zero-copy nativeview_abi::table::NvTableView entries for every
PUBLISH_TO_SCENE table currently allocated in this store — zero heap allocations when
out and owners_buf have sufficient capacity.
Both dirty_owners (from TableChanges::nodes, excluding swap-remove relocations) and
detached_owners (from TableChanges::detached, live nodes that no longer carry the table)
are sorted by raw NodeId and deduplicated per table inside owners_buf (which must live
as long as out is read).
detached_owners is an idempotent teardown signal: consumers must treat detaching an owner
that was never mounted as a no-op (e.g. a same-frame attach+detach on an existing live node
emits detached_owners on a direct store or merged ChangeSet, whereas an NV02 replica
that never observed the transient attach emits none).
Source§impl NodeStore
impl NodeStore
Sourcepub fn events_word(&self, slot: TableSlot) -> u8
pub fn events_word(&self, slot: TableSlot) -> u8
Word holding the EventSet listener bitmask for slot, or nativeview_abi::table::NO_VAL_WORD
when slot has no events or is not installed in this store.
Sourcepub fn node_events_mask(&self, slot: TableSlot, id: NodeId) -> u32
pub fn node_events_mask(&self, slot: TableSlot, id: NodeId) -> u32
Raw 32-bit EventSet listener bitmask on live node id for slot (0 if absent or no
events).
Sourcepub fn schema_hash_with_base(&self, base_descs: &[&'static TableDesc]) -> u64
pub fn schema_hash_with_base(&self, base_descs: &[&'static TableDesc]) -> u64
Deterministic 64-bit XXH64 schema digest over base_descs unioned with every table
actually attached to at least one live node in this store (both compiled static and
wire-declared dynamic tables). Matches [crate::tables_schema_hash(base_descs)] when
only tables in base_descs are live.
Sourcepub fn table_slots(&self) -> impl Iterator<Item = TableSlot> + '_
pub fn table_slots(&self) -> impl Iterator<Item = TableSlot> + '_
Slots of every table that has a column in this store.
Sourcepub fn for_each_owner_referencing_resources(
&self,
slot: TableSlot,
is_changed: impl FnMut(ResourceId) -> bool,
f: impl FnMut(NodeId),
)
pub fn for_each_owner_referencing_resources( &self, slot: TableSlot, is_changed: impl FnMut(ResourceId) -> bool, f: impl FnMut(NodeId), )
Invokes f once for every live row owner in slot (sparse or dense) storing a ResourceId
matching is_changed. Uses TableDesc::resource_words when registered, falling back to
scanning every word of the row when no descriptor exists (including rows wider than 32 words).
Sourcepub fn for_each_slot_owner_referencing_changed_resources(
&self,
slots: &[TableSlot],
changes: &ChangeSet,
f: impl FnMut(TableSlot, NodeId),
)
pub fn for_each_slot_owner_referencing_changed_resources( &self, slots: &[TableSlot], changes: &ChangeSet, f: impl FnMut(TableSlot, NodeId), )
Visits every (slot, owner) across slots whose row references a resource in
changes.resources_defined or changes.resources_released, automatically switching from
linear scan (<= 4 changed resources) to a FastBuildHasher set (> 4).
Sourcepub fn table_storage(&self, slot: TableSlot) -> Option<TableStorage<'_>>
pub fn table_storage(&self, slot: TableSlot) -> Option<TableStorage<'_>>
A table’s storage exactly as published in NvTableView.
Sourcepub fn row_owners<T: NvTable>(&self) -> &[NodeId]
pub fn row_owners<T: NvTable>(&self) -> &[NodeId]
The owner of every row of the sparse table T, in row order: rows swap-remove on detach,
so each entry is a live node owning a T row. O(rows) iteration instead of a scan over
every slot. A dense T is a compile error (it has no owner list).
pub fn stats(&self) -> StoreStats
Source§impl NodeStore
impl NodeStore
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a store holding only the root node (NodeId::ROOT).
Sourcepub fn instance_id(&self) -> u64
pub fn instance_id(&self) -> u64
Process-unique, never-reused identity of this store and its resource namespace (never 0).
Unlike its address it changes when a store is replaced in place (*store = NodeStore::new()), so consumers caching per-store state detect every switch.
Sourcepub fn replica() -> Self
pub fn replica() -> Self
Creates an empty replica store (no root): every node, including the root, arrives through
wire::WireDecoder::apply.
Sourcepub fn reserve_for_frame0(
&mut self,
node_count: usize,
payload_bytes: usize,
) -> Result<(), WireError>
pub fn reserve_for_frame0( &mut self, node_count: usize, payload_bytes: usize, ) -> Result<(), WireError>
Fallibly pre-sizes core arenas ahead of a bulk NV02 apply (O(1) allocs independent of N),
bounding node_count by payload_bytes / 4 and NodeId::MAX_INDEX.
Sourcepub fn set_realization_order(&mut self, order: RealizationOrder)
pub fn set_realization_order(&mut self, order: RealizationOrder)
Installs the backend’s ordered realization priority list used to derive
NodeRow::primary_slot at commit, merging any already-installed declarative realizing
columns (realization_priority > 0) not explicitly listed in order.
Sourcepub fn commit_epoch(&self) -> u64
pub fn commit_epoch(&self) -> u64
Monotonic commit epoch bumped on every Transaction::commit_into.
Sourcepub fn stacking_context_tables(&self) -> TableSet
pub fn stacking_context_tables(&self) -> TableSet
Bitset of installed tables whose table_flags::STACKING_CONTEXT bit is set.
Sourcepub fn inherits_typography_slots(&self) -> TableSet
pub fn inherits_typography_slots(&self) -> TableSet
Bitset of installed tables whose table_flags::INHERITS_TYPOGRAPHY bit is set.
Sourcepub fn node_tables(&self, id: NodeId) -> TableSet
pub fn node_tables(&self, id: NodeId) -> TableSet
Attached table bitset of live node id (TableSet::EMPTY when dead).
pub fn is_live(&self, id: NodeId) -> bool
Sourcepub fn is_connected(&self, id: NodeId) -> bool
pub fn is_connected(&self, id: NodeId) -> bool
true when id is live and connected to NodeId::ROOT.
Sourcepub fn get(&self, id: NodeId) -> Option<NodeRef<'_>>
pub fn get(&self, id: NodeId) -> Option<NodeRef<'_>>
Validates id once (bounds + LIVE + generation) and returns a zero-cost NodeRef.
Sourcepub fn id_at(&self, index: usize) -> Option<NodeId>
pub fn id_at(&self, index: usize) -> Option<NodeId>
Live NodeId currently occupying index (None if free).
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Number of node slots (including the null slot 0 and free slots).
Sourcepub fn node_rows(&self) -> &[NodeRow]
pub fn node_rows(&self) -> &[NodeRow]
Dense contiguous slice of all NodeRow slots (slot 0 is reserved null; live nodes live
in 1..capacity() with flags & LIVE != 0). Published zero-copy in NvSceneView.
Sourcepub fn live_nodes(&self) -> impl Iterator<Item = NodeId> + '_
pub fn live_nodes(&self) -> impl Iterator<Item = NodeId> + '_
Iterates every live node id.
pub fn parent(&self, id: NodeId) -> Option<NodeId>
pub fn children(&self, id: NodeId) -> &[NodeId]
pub fn primary_slot(&self, id: NodeId) -> TableSlot
Sourcepub fn is_inline(&self, id: NodeId) -> bool
pub fn is_inline(&self, id: NodeId) -> bool
true when id is live and carries NV_NODE_ROW_FLAG_INLINE (descendant of a paragraph root).
Sourcepub fn inline_context_slots(&self) -> TableSet
pub fn inline_context_slots(&self) -> TableSet
Bitset of table slots installed in this store that carry table_flags::INLINE_CONTEXT.
Sourcepub fn is_inline_context_root(&self, id: NodeId) -> bool
pub fn is_inline_context_root(&self, id: NodeId) -> bool
true when live non-inline node id establishes an inline formatting context (paragraph root).
pub fn has<T: NvTable>(&self, id: NodeId) -> bool
pub fn has_slot(&self, id: NodeId, slot: TableSlot) -> bool
Sourcepub fn words(&self, id: NodeId, slot: TableSlot) -> Option<&[Word]>
pub fn words(&self, id: NodeId, slot: TableSlot) -> Option<&[Word]>
Raw words of slot’s row on id, if attached.
Sourcepub fn try_row<T: NvTable>(&self, id: NodeId) -> Option<T::Ref<'_>>
pub fn try_row<T: NvTable>(&self, id: NodeId) -> Option<T::Ref<'_>>
Typed row of T on id, if attached.
Sourcepub fn row<T: NvTable>(&self, id: NodeId) -> T::Ref<'_>
pub fn row<T: NvTable>(&self, id: NodeId) -> T::Ref<'_>
Typed row of T on id, or the table defaults when not attached.
Sourcepub fn row_from_words<'a, T: NvTable>(&'a self, words: &'a [Word]) -> T::Ref<'a>
pub fn row_from_words<'a, T: NvTable>(&'a self, words: &'a [Word]) -> T::Ref<'a>
Zero-copy typed reader over a caller-owned word buffer (e.g. a stack [Word; N] overlaid
with a [RowPatchView]). Requires T to contain no string words (T::DESC.str_words == 0)
so caller-synthesized words can never index out of StrArena.
Sourcepub fn copy_row_words<T: NvTable>(&self, id: NodeId, out: &mut [Word])
pub fn copy_row_words<T: NvTable>(&self, id: NodeId, out: &mut [Word])
Copies the raw words of T on id (or T::DESC.defaults if unattached) into out.
Sourcepub fn try_text(&self, span: StrSpan) -> Option<&str>
pub fn try_text(&self, span: StrSpan) -> Option<&str>
Checked UTF-8 text lookup for a detached StrSpan (None if stale or invalid UTF-8).
Sourcepub fn text(&self, span: StrSpan) -> &str
pub fn text(&self, span: StrSpan) -> &str
Checked UTF-8 text lookup for a detached StrSpan (prefer direct row.<field>() getters
for O(1) unchecked &str reads tied to the store borrow).
Sourcepub fn text_slab(&self) -> &[u8] ⓘ
pub fn text_slab(&self) -> &[u8] ⓘ
The contiguous UTF-8 text slab (published as NvSceneView::text_slab).
Sourcepub fn children_slab(&self) -> &[NodeId]
pub fn children_slab(&self) -> &[NodeId]
The contiguous child id slab (published as NvSceneView::children_slab).
pub fn resources(&self) -> &ResourceStore
pub fn resource<R: FlatResource>(&self, id: ResourceId) -> Option<R::View<'_>>
Sourcepub fn table_desc(&self, slot: TableSlot) -> Option<&'static TableDesc>
pub fn table_desc(&self, slot: TableSlot) -> Option<&'static TableDesc>
Descriptor of a compiled/static table slot used in this store.