Skip to main content

LiveSession

Struct LiveSession 

Source
pub struct LiveSession<T: Lerp> { /* private fields */ }
Expand description

一条共享轨道上的临时呈现事务。

commit 回调在 commit() 内同步执行,负责把终值写回 Signal/State;这样 “写入权转移”和 generation bump 是同一瞬间,外部不会看到半提交状态。

Implementations§

Source§

impl<T: Lerp + 'static> LiveSession<T>

Source

pub fn new(track: SharedTrack<T>, commit: impl Fn(T) + 'static) -> Self

用现有共享轨道建会话。commit 只应在 commit() 里由框架调用。

Source

pub fn phase(&self) -> LivePhase

Source

pub fn generation(&self) -> u64

Source

pub fn is_active(&self) -> bool

Source

pub fn start(&self, scope: &'static str, now_ms: u64) -> LiveHandle<T>

开始一次手势。若上一段仍 Active,先按 CaptureLost 终态收掉再开新段。

Source

pub fn update(&self, handle: &LiveHandle<T>, value: T, now_ms: u64) -> bool

高频更新:只写轨道呈现位,绝不触碰 Signal/tree/semantics。 token 失配时静默忽略(旧手势、外部 set 之后的迟到事件)。

Source

pub fn commit( &self, handle: &LiveHandle<T>, now_ms: u64, ) -> Option<LiveOutcome<T>>

提交:写回逻辑状态、结算呈现位、交还所有权。

Source

pub fn cancel( &self, handle: &LiveHandle<T>, reason: LiveReason, now_ms: u64, ) -> Option<LiveOutcome<T>>

取消:回滚到当前逻辑目标,而不是过期的 start 值。

Source

pub fn invalidate( &self, reason: LiveReason, now_ms: u64, ) -> Option<LiveOutcome<T>>

外部原因使活跃手势失效(失焦、最小化、卸载、外部 Signal 等)。

Source

pub fn external_set(&self, value: T, now_ms: u64)

逻辑目标被外部改写:先 bump generation 使旧 token 失效,再把新值作为呈现真值。

Source

pub fn consume_semantics_bump(&self) -> bool

语义树终态发布:Active 期间为 false,终态几何变化时为 true,读一次即清。

Source

pub fn debug_assert_settled(&self, rebuilt_presented: T)

Debug 一致性校验:rebuild 后的 RO 呈现值必须与事务结算值一致。

Trait Implementations§

Source§

impl<T: Lerp + 'static> Clone for LiveSession<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Lerp> Debug for LiveSession<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for LiveSession<T>

§

impl<T> !Send for LiveSession<T>

§

impl<T> !Sync for LiveSession<T>

§

impl<T> !UnwindSafe for LiveSession<T>

§

impl<T> Forget for LiveSession<T>

§

impl<T> Freeze for LiveSession<T>
where Rc<RefCell<LiveInner<T>>>: Freeze, Rc<RefCell<dyn Track<T>>>: Freeze, Rc<dyn Fn(T)>: Freeze,

§

impl<T> Move for LiveSession<T>

§

impl<T> Unpin for LiveSession<T>
where Rc<RefCell<LiveInner<T>>>: Unpin, Rc<RefCell<dyn Track<T>>>: Unpin, Rc<dyn Fn(T)>: Unpin,

§

impl<T> UnsafeUnpin for LiveSession<T>
where Rc<RefCell<LiveInner<T>>>: UnsafeUnpin, Rc<RefCell<dyn Track<T>>>: UnsafeUnpin, Rc<dyn Fn(T)>: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.