Skip to main content

NodeStore

Struct NodeStore 

Source
pub struct NodeStore { /* private fields */ }
Expand description

The single owner of every node, table row, child list, string, and resource.

Implementations§

Source§

impl NodeStore

Source

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

Source

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.

Source

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).

Source

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.

Source

pub fn table_slots(&self) -> impl Iterator<Item = TableSlot> + '_

Slots of every table that has a column in this store.

Source

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).

Source

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).

Source

pub fn table_storage(&self, slot: TableSlot) -> Option<TableStorage<'_>>

A table’s storage exactly as published in NvTableView.

Source

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).

Source

pub fn stats(&self) -> StoreStats

Source§

impl NodeStore

Source

pub fn new() -> Self

Creates a store holding only the root node (NodeId::ROOT).

Source

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.

Source

pub fn replica() -> Self

Creates an empty replica store (no root): every node, including the root, arrives through wire::WireDecoder::apply.

Source

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.

Source

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.

Source

pub fn frame(&self) -> u64

Frames committed so far.

Source

pub fn commit_epoch(&self) -> u64

Monotonic commit epoch bumped on every Transaction::commit_into.

Source

pub fn stacking_context_tables(&self) -> TableSet

Bitset of installed tables whose table_flags::STACKING_CONTEXT bit is set.

Source

pub fn inherits_typography_slots(&self) -> TableSet

Bitset of installed tables whose table_flags::INHERITS_TYPOGRAPHY bit is set.

Source

pub fn node_tables(&self, id: NodeId) -> TableSet

Attached table bitset of live node id (TableSet::EMPTY when dead).

Source

pub fn is_live(&self, id: NodeId) -> bool

Source

pub fn is_connected(&self, id: NodeId) -> bool

true when id is live and connected to NodeId::ROOT.

Source

pub fn get(&self, id: NodeId) -> Option<NodeRef<'_>>

Validates id once (bounds + LIVE + generation) and returns a zero-cost NodeRef.

Source

pub fn node(&self, id: NodeId) -> Option<&NodeRow>

Hot record of a live node.

Source

pub fn id_at(&self, index: usize) -> Option<NodeId>

Live NodeId currently occupying index (None if free).

Source

pub fn capacity(&self) -> usize

Number of node slots (including the null slot 0 and free slots).

Source

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.

Source

pub fn live_nodes(&self) -> impl Iterator<Item = NodeId> + '_

Iterates every live node id.

Source

pub fn parent(&self, id: NodeId) -> Option<NodeId>

Source

pub fn children(&self, id: NodeId) -> &[NodeId]

Source

pub fn primary_slot(&self, id: NodeId) -> TableSlot

Source

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).

Source

pub fn inline_context_slots(&self) -> TableSet

Bitset of table slots installed in this store that carry table_flags::INLINE_CONTEXT.

Source

pub fn is_inline_context_root(&self, id: NodeId) -> bool

true when live non-inline node id establishes an inline formatting context (paragraph root).

Source

pub fn has<T: NvTable>(&self, id: NodeId) -> bool

Source

pub fn has_slot(&self, id: NodeId, slot: TableSlot) -> bool

Source

pub fn words(&self, id: NodeId, slot: TableSlot) -> Option<&[Word]>

Raw words of slot’s row on id, if attached.

Source

pub fn try_row<T: NvTable>(&self, id: NodeId) -> Option<T::Ref<'_>>

Typed row of T on id, if attached.

Source

pub fn row<T: NvTable>(&self, id: NodeId) -> T::Ref<'_>

Typed row of T on id, or the table defaults when not attached.

Source

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.

Source

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.

Source

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).

Source

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).

Source

pub fn text_slab(&self) -> &[u8] ⓘ

The contiguous UTF-8 text slab (published as NvSceneView::text_slab).

Source

pub fn children_slab(&self) -> &[NodeId]

The contiguous child id slab (published as NvSceneView::children_slab).

Source

pub fn resources(&self) -> &ResourceStore

Source

pub fn resource<R: FlatResource>(&self, id: ResourceId) -> Option<R::View<'_>>

Source

pub fn table_desc(&self, slot: TableSlot) -> Option<&'static TableDesc>

Descriptor of a compiled/static table slot used in this store.

Source

pub fn table_key(&self, slot: TableSlot) -> Option<TableKey>

Canonical nativeview_abi::table::TableKey of any installed table (static or wire-declared).

Source§

impl NodeStore

Source

pub fn tx(&mut self) -> Transaction<'_>

Opens a mutation scope. Changes accumulate across transactions until commit_into.

Trait Implementations§

Source§

impl Default for NodeStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for NodeStore

§

impl Freeze for NodeStore

§

impl Move for NodeStore

§

impl RefUnwindSafe for NodeStore

§

impl Send for NodeStore
where RawVecInner: Send, &'static TableDesc: Send, Arc<OwnedTableDesc>: Send, OnceLock<TypeId>: Send, RawTable<((u64, u64), ResourceId)>: Send,

§

impl Sync for NodeStore
where RawVecInner: Sync, Arc<OwnedTableDesc>: Sync, OnceLock<TypeId>: Sync, RawTable<((u64, u64), ResourceId)>: Sync,

§

impl Unpin for NodeStore
where *const u8 is !null: Unpin, &'static TableDesc: Unpin, Arc<OwnedTableDesc>: Unpin, Align4<u32>: Unpin, *const (): Unpin,

§

impl UnsafeUnpin for NodeStore

§

impl UnwindSafe for NodeStore

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> 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, 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.