Skip to main content

Transaction

Struct Transaction 

Source
pub struct Transaction<'s> { /* private fields */ }
Expand description

Mutable frame scope over a NodeStore: TxCore plus commit_into.

Implementations§

Source§

impl Transaction<'_>

Source

pub fn commit_into(self, changes: &mut ChangeSet)

Closes the frame: refills changes in place (zero steady-state allocations) and clears all per-frame tracking. Removed node indices and released resources are recycled afterwards, so ids seen in this frame never alias within it.

Methods from Deref<Target = TxCore<'s>>§

Source

pub fn try_set_children( &mut self, parent: NodeId, new_children: &[NodeId], ) -> bool

Validated child-list replacement returning false without mutating the tree if parent is dead, any child is non-live/NULL, any child is duplicated, or any child would form a cycle. Fallible version of Self::set_children returning false on dead/NULL/duplicate/cyclic input.

Source

pub fn set_children(&mut self, parent: NodeId, new_children: &[NodeId])

Replaces the ordered child list of parent (no-op when unchanged or invalid, zero heap allocations). Rejects dead/null nodes, duplicates, and cycles; detaches moved children from any previous parent.

Source

pub fn insert_child(&mut self, parent: NodeId, index: usize, child: NodeId)

Inserts child at index (clamped) in parent’s child list, moving it from any previous parent (zero heap allocations via SpanPool::insert_at). Ignores dead nodes or cycles.

Source

pub fn append_child(&mut self, parent: NodeId, child: NodeId)

Appends child to parent (zero heap allocations).

Source

pub fn detach_child(&mut self, child: NodeId)

Detaches child from its parent (the child stays alive).

Source

pub fn store(&self) -> &NodeStore

Read access to the store mid-transaction.

Source

pub fn create(&mut self) -> NodeId

Allocates a node (detached, no tables).

Source

pub fn spawn(&mut self) -> NodeMut<'_>

Allocates a node and returns a validated NodeMut handle for chained zero-check edits.

Source

pub fn node_mut(&mut self, id: NodeId) -> Option<NodeMut<'_>>

Validates id once and returns a NodeMut handle (None if dead/stale).

Source

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

Creates id exactly (replica stores applying a wire frame). Returns false if the slot is occupied by a live node. O(1) — clears IN_FREE/PENDING_FREE flags without scanning.

Source

pub fn remove(&mut self, id: NodeId)

Removes id and its whole subtree, detaching it from its parent (zero heap allocations once scratch_stack is warm). Records removed in postorder (descendants before ancestors).

Source

pub fn edit<T: NvTable>(&mut self, id: NodeId) -> T::Mut<'_>

Fluent typed writer for T on id (attaches T with defaults when absent).

Source

pub fn attach<T: NvTable>(&mut self, id: NodeId)

Attaches T with its defaults (no-op if attached).

Source

pub fn set<T: NvTable, V: ScalarField>( &mut self, id: NodeId, prop: Prop<T, V>, value: V, )

Sets one scalar or wide-optional property.

Source

pub fn set_str<T: NvTable>(&mut self, id: NodeId, prop: StrProp<T>, text: &str)

Sets one string property.

Source

pub fn with_temp_resources<R>( &mut self, f: impl FnOnce(&mut TempResources<'_>) -> R, ) -> R

Opens a leak-free temporary resource scope for building nested resources (e.g. ResponsiveRules / StateRules embedding child BackgroundFillRes / GridTracks).

Source

pub fn set_resource<T: NvTable, R: FlatResource>( &mut self, id: NodeId, prop: ResProp<T, R>, value: Option<&R>, )

Sets (interned) or clears one resource property.

Source

pub fn set_resource_with<T: NvTable, R: FlatResource>( &mut self, id: NodeId, prop: ResProp<T, R>, write: impl FnOnce(&mut Vec<u32>) -> bool, )

Sets (interned) one resource property via a zero-alloc scratch-word closure.

Source

pub fn set_resource_id<T: NvTable, R: FlatResource>( &mut self, id: NodeId, prop: ResProp<T, R>, rid: ResourceId, ) -> bool

Points one resource property at a live ResourceId of type R (or ResourceId::NONE). Returns false without mutating if rid is stale, dead, or of a mismatched kind/type.

Source

pub fn apply_row_patch(&mut self, id: NodeId, patch: RowPatchView<'_>)

Applies every valid table operation in patch onto live node id, attaching a touched table only when at least one non-metadata op passes word, liveness, and resource-kind checks. On #[nv_table(inherited)] tables, explicit bits belonging to skipped ops or forged/orphan word-0 set bits lacking all accompanying data-word ops are masked out before updating word 0 so rejected or unpatched fields never override inherited values.

Source

pub fn mark_table_paint_dirty<T: NvTable>(&mut self, id: NodeId)

Marks an existing row of table T on live node id as paint-dirty without mutating its authored words, so both ChangeSet::touched (effect::PAINT) and NvTableView::dirty_owners report it for the current frame (zero steady-state allocations).

Source

pub fn detach<T: NvTable>(&mut self, id: NodeId)

Detaches table T from id, releasing its strings and resources.

Source

pub fn detach_slot(&mut self, id: NodeId, slot: TableSlot)

Trait Implementations§

Source§

impl<'s> Deref for Transaction<'s>

Source§

type Target = TxCore<'s>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &TxCore<'s>

Dereferences the value.
Source§

impl DerefMut for Transaction<'_>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'s> !UnwindSafe for Transaction<'s>

§

impl<'s> Forget for Transaction<'s>

§

impl<'s> Freeze for Transaction<'s>
where &'s mut NodeStore: Freeze,

§

impl<'s> Move for Transaction<'s>

§

impl<'s> RefUnwindSafe for Transaction<'s>

§

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

§

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

§

impl<'s> Unpin for Transaction<'s>
where &'s mut NodeStore: Unpin,

§

impl<'s> UnsafeUnpin for Transaction<'s>
where &'s mut NodeStore: UnsafeUnpin,

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.