pub trait Animation<Value>: Send + Sync {
// Required method
fn sample(&self, time: Time) -> Value;
// Provided methods
fn duration(&self) -> Option<Duration> { ... }
fn map<Output, Function>(
self,
function: Function,
) -> Map<Self, Function, Value>
where Self: Sized,
Function: Fn(Value) -> Output + Send + Sync { ... }
fn zip<OtherValue, Other>(self, other: Other) -> Zip<Self, Other>
where Self: Sized,
Other: Animation<OtherValue> { ... }
fn delay(self, offset: Duration) -> Delay<Self>
where Self: Sized { ... }
fn speed(self, factor: f64) -> Speed<Self>
where Self: Sized { ... }
fn then<Next: Animation<Value>>(self, next: Next) -> Then<Self, Next>
where Self: Sized { ... }
fn reverse(self) -> Reverse<Self>
where Self: Sized { ... }
fn repeat(self, count: u32) -> Repeat<Self>
where Self: Sized { ... }
fn ping_pong(self) -> PingPong<Self>
where Self: Sized { ... }
fn boxed(self) -> Arc<dyn Animation<Value>> ⓘ
where Self: Sized + 'static { ... }
}Expand description
A thread-safe, randomly addressable animation of values.
Finite implementations hold their endpoint values outside [0, duration].
Infinite implementations may use negative time. Sampling must not depend on
earlier calls. A reported duration must be nonnegative and stable.
Required Methods§
Provided Methods§
Sourcefn duration(&self) -> Option<Duration>
fn duration(&self) -> Option<Duration>
Returns the finite duration, or None for an unbounded signal.
Sourcefn map<Output, Function>(self, function: Function) -> Map<Self, Function, Value>
fn map<Output, Function>(self, function: Function) -> Map<Self, Function, Value>
Transforms values without changing timing.
Sourcefn zip<OtherValue, Other>(self, other: Other) -> Zip<Self, Other>
fn zip<OtherValue, Other>(self, other: Other) -> Zip<Self, Other>
Samples in parallel; the duration is infinite if either input is infinite.
Sourcefn delay(self, offset: Duration) -> Delay<Self>where
Self: Sized,
fn delay(self, offset: Duration) -> Delay<Self>where
Self: Sized,
Delays a finite animation, holding its initial value before the offset. Infinite signals shift their signed time instead. Negative offsets and finite duration overflow panic at construction.
Sourcefn speed(self, factor: f64) -> Speed<Self>where
Self: Sized,
fn speed(self, factor: f64) -> Speed<Self>where
Self: Sized,
Changes playback speed by a finite, strictly positive factor. Durations round to the nearest tick; a collapsed finite animation becomes instantaneous. Invalid factors and unrepresentable durations panic.
Sourcefn then<Next: Animation<Value>>(self, next: Next) -> Then<Self, Next>where
Self: Sized,
fn then<Next: Animation<Value>>(self, next: Next) -> Then<Self, Next>where
Self: Sized,
Runs two finite animations in sequence. The second owns their shared boundary. Infinite sources or duration overflow panic at construction.
Sourcefn reverse(self) -> Reverse<Self>where
Self: Sized,
fn reverse(self) -> Reverse<Self>where
Self: Sized,
Reverses a finite animation. Infinite sources panic at construction.
Sourcefn repeat(self, count: u32) -> Repeat<Self>where
Self: Sized,
fn repeat(self, count: u32) -> Repeat<Self>where
Self: Sized,
Plays a finite animation count times. Intermediate boundaries restart;
the final boundary holds the target. Zero repeats hold the initial value.
Infinite sources or duration overflow panic at construction.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".