Skip to main content

Eval

Trait Eval 

Source
pub trait Eval {
    type Output;

    // Required method
    fn eval_alpha(&self, alpha: f64) -> Self::Output;

    // Provided method
    fn sim_step(&self) -> Option<f64> { ... }
}
Expand description

The general animation segment protocol: what the runtime can do with a segment.

An animation’s content is immutable once defined: it is a pure function of its own normalized progress alpha ∈ [0, 1]. The protocol exposes a single entry — eval_alpha — and it is a pure query on &self (evaluating the same alpha always yields the same Output, regardless of call order or repetition). No evaluator sees seconds or the scene clock; the owning cell remaps time to progress before calling in.

Stateful (iterative) segments memoize their integration behind a snapshot so repeated queries are cheap; pure segments are a closed form. The standard author-facing adapters live here too: Iterative turns an IterativeEval step function into an Eval, and Pure wraps a raw closure Fn(f64) -> T. Implementing Eval directly remains the path for exotic segments.

Required Associated Types§

Source

type Output

Value produced by this evaluator.

Required Methods§

Source

fn eval_alpha(&self, alpha: f64) -> Self::Output

Evaluate the segment’s content at normalized progress alpha.

Provided Methods§

Source

fn sim_step(&self) -> Option<f64>

The content resolution declared by iterative segments: 1/N progress per integration step (N declared via Iterative::with_steps).

None for non-iterative segments. This is an introspection query for tooling (e.g. ranim inspect tree); it does not affect evaluation.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<E> Eval for Iterative<E>
where E: IterativeEval, E::Output: Clone,

Source§

impl<T, F> Eval for Pure<F>
where F: Fn(f64) -> T,

Source§

impl<T: Clone> Eval for Static<T>