Skip to main content

SceneTransaction

Struct SceneTransaction 

Source
pub struct SceneTransaction<'a> { /* private fields */ }
Expand description

An open transaction over a SceneModel: every edit until it drops is one logical change.

Opened by SceneModel::transaction / SceneModel::user_edit. On drop it closes the scope and — with an edit sink installed — delivers one SceneTransactionRecord with the scene unborrowed.

Nesting joins: a guard opened while another is live adds no boundary, and the outer stamp wins. Everything a guard says (squash, ephemeral, abandon) therefore applies to the transaction it is part of, not to a private one of its own.

Implementations§

Source§

impl SceneTransaction<'_>

Source

pub fn squash(self) -> Self

Coalesce this transaction’s repeated writes to one continuous quantity — position, bounds, transform, opacity, z, placement — into a single edit keeping the first old and the last new.

Off by default, and deliberately: squashing throws the intermediate path away, which a replay, a presence indicator or a collaboration relay needs, and losing it silently by default is exactly the quiet data loss this seam exists to prevent. The built-in item drag already commits one set_local_pos per gesture, so the default costs nothing in the common case; a caller that writes per sample and wants endpoints asks for it.

Discrete edits — adds, removals, replacements, flags, parent changes — are never coalesced and keep their order.

Source

pub fn ephemeral(self) -> Self

Mark this transaction’s changes as per-frame artefacts: they must be rendered and must not be recorded.

The app-side half of the knob the scene’s own dynamic-bounds refresh uses. An item whose transform follows a rotation Signal writes the model every frame; without this, an app watching the change stream cannot tell that churn from an edit. ephemeral rides every SceneChange and the record, and the framework does nothing else with it — what counts as history is the consumer’s call.

Source

pub fn abandon(self)

Mark the interaction cancelled, then commit.

The scene is not rolled back: applying an inverse is the first 80 % of an undo stack, and undo lives on the other side of this seam. The record arrives with TxnOutcome::Abandoned so the consumer can revert from the old values it was handed without pushing anything a redo could replay — tldraw’s bail, with the stack where it belongs.

On a nested guard this abandons the transaction it joined, because that is the transaction it is part of.

Trait Implementations§

Source§

impl Debug for SceneTransaction<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for SceneTransaction<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for SceneTransaction<'a>

§

impl<'a> !Send for SceneTransaction<'a>

§

impl<'a> !Sync for SceneTransaction<'a>

§

impl<'a> !UnwindSafe for SceneTransaction<'a>

§

impl<'a> Freeze for SceneTransaction<'a>

§

impl<'a> Unpin for SceneTransaction<'a>

§

impl<'a> UnsafeUnpin for SceneTransaction<'a>

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more