pub trait Track<T: Lerp>: Debug {
// Required methods
fn presented(&self) -> T;
fn target(&self) -> T;
fn set_presented(&mut self, value: T, now_ms: u64);
fn settle_live(&mut self, value: T, now_ms: u64);
fn tick(&mut self, now_ms: u64) -> T;
fn retarget(&mut self, target: T, now_ms: u64);
fn is_animating(&self) -> bool;
fn is_settled(&self) -> bool;
}Expand description
属性轨道的统一契约。
PropertyTrack(时长 + 曲线、到点即停)与 SpringTrack
都实现它,widget/state 只依赖句柄 SharedTrack<T>,不再为每种轨道复制
一套 AnimatedXxxWidget —— 消灭“轨道类型 × 属性“的 N×M 样板。
value_at(无状态查询未来值)刻意不进 trait:只有曲线轨道有,弹簧按固定
步积分、无法无状态预知;需要“立即读当前值“的路径统一走 presented。
Required Methods§
fn presented(&self) -> T
fn target(&self) -> T
Sourcefn set_presented(&mut self, value: T, now_ms: u64)
fn set_presented(&mut self, value: T, now_ms: u64)
live_only 呈现位直写;不产生响应式副作用、不改逻辑目标。
Sourcefn settle_live(&mut self, value: T, now_ms: u64)
fn settle_live(&mut self, value: T, now_ms: u64)
结束 live 接管并把终值结算为新的逻辑目标。
fn tick(&mut self, now_ms: u64) -> T
fn retarget(&mut self, target: T, now_ms: u64)
fn is_animating(&self) -> bool
fn is_settled(&self) -> bool
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".