pub struct LiveSession<T: Lerp> { /* private fields */ }Expand description
一条共享轨道上的临时呈现事务。
commit 回调在 commit() 内同步执行,负责把终值写回 Signal/State;这样
“写入权转移”和 generation bump 是同一瞬间,外部不会看到半提交状态。
Implementations§
Source§impl<T: Lerp + 'static> LiveSession<T>
impl<T: Lerp + 'static> LiveSession<T>
Sourcepub fn new(track: SharedTrack<T>, commit: impl Fn(T) + 'static) -> Self
pub fn new(track: SharedTrack<T>, commit: impl Fn(T) + 'static) -> Self
用现有共享轨道建会话。commit 只应在 commit() 里由框架调用。
pub fn phase(&self) -> LivePhase
pub fn generation(&self) -> u64
pub fn is_active(&self) -> bool
Sourcepub fn start(&self, scope: &'static str, now_ms: u64) -> LiveHandle<T>
pub fn start(&self, scope: &'static str, now_ms: u64) -> LiveHandle<T>
开始一次手势。若上一段仍 Active,先按 CaptureLost 终态收掉再开新段。
Sourcepub fn update(&self, handle: &LiveHandle<T>, value: T, now_ms: u64) -> bool
pub fn update(&self, handle: &LiveHandle<T>, value: T, now_ms: u64) -> bool
高频更新:只写轨道呈现位,绝不触碰 Signal/tree/semantics。 token 失配时静默忽略(旧手势、外部 set 之后的迟到事件)。
Sourcepub fn commit(
&self,
handle: &LiveHandle<T>,
now_ms: u64,
) -> Option<LiveOutcome<T>>
pub fn commit( &self, handle: &LiveHandle<T>, now_ms: u64, ) -> Option<LiveOutcome<T>>
提交:写回逻辑状态、结算呈现位、交还所有权。
Sourcepub fn cancel(
&self,
handle: &LiveHandle<T>,
reason: LiveReason,
now_ms: u64,
) -> Option<LiveOutcome<T>>
pub fn cancel( &self, handle: &LiveHandle<T>, reason: LiveReason, now_ms: u64, ) -> Option<LiveOutcome<T>>
取消:回滚到当前逻辑目标,而不是过期的 start 值。
Sourcepub fn invalidate(
&self,
reason: LiveReason,
now_ms: u64,
) -> Option<LiveOutcome<T>>
pub fn invalidate( &self, reason: LiveReason, now_ms: u64, ) -> Option<LiveOutcome<T>>
外部原因使活跃手势失效(失焦、最小化、卸载、外部 Signal 等)。
Sourcepub fn external_set(&self, value: T, now_ms: u64)
pub fn external_set(&self, value: T, now_ms: u64)
逻辑目标被外部改写:先 bump generation 使旧 token 失效,再把新值作为呈现真值。
Sourcepub fn consume_semantics_bump(&self) -> bool
pub fn consume_semantics_bump(&self) -> bool
语义树终态发布:Active 期间为 false,终态几何变化时为 true,读一次即清。
Sourcepub fn debug_assert_settled(&self, rebuilt_presented: T)
pub fn debug_assert_settled(&self, rebuilt_presented: T)
Debug 一致性校验:rebuild 后的 RO 呈现值必须与事务结算值一致。
Trait Implementations§
Source§impl<T: Lerp + 'static> Clone for LiveSession<T>
impl<T: Lerp + 'static> Clone for LiveSession<T>
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
*const RcInner<RefCell<LiveInner<T>>> is !null: Freeze,
PhantomData<RcInner<RefCell<LiveInner<T>>>>: Freeze,
*const RcInner<RefCell<dyn Track<T>>> is !null: Freeze,
PhantomData<RcInner<RefCell<dyn Track<T>>>>: Freeze,
*const RcInner<dyn Fn(T)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(T)>>: Freeze,
impl<T> Move for LiveSession<T>
impl<T> Unpin for LiveSession<T>
impl<T> UnsafeUnpin for LiveSession<T>where
*const RcInner<RefCell<LiveInner<T>>> is !null: UnsafeUnpin,
PhantomData<RcInner<RefCell<LiveInner<T>>>>: UnsafeUnpin,
*const RcInner<RefCell<dyn Track<T>>> is !null: UnsafeUnpin,
PhantomData<RcInner<RefCell<dyn Track<T>>>>: UnsafeUnpin,
*const RcInner<dyn Fn(T)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(T)>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more