Skip to main content

AnimatedDataSystem

Trait AnimatedDataSystem 

Source
pub trait AnimatedDataSystem:
    Clone
    + Debug
    + PartialEq
    + Eq
    + Hash
    + Send
    + Sync
    + 'static {
    type Data: DataSystem<Animated = Self>;

    // Required methods
    fn keyframe_count(&self) -> usize;
    fn times(&self) -> SmallVec<[Time; 10]>;
    fn interpolate(&self, time: Time) -> Self::Data;
    fn sample_at(&self, time: Time) -> Option<Self::Data>;
    fn try_insert(&mut self, time: Time, value: Self::Data) -> Result<()>;
    fn remove_at(&mut self, time: &Time) -> Option<Self::Data>;
    fn discriminant(&self) -> <Self::Data as DataSystem>::DataType;
    fn from_single(time: Time, value: Self::Data) -> Self;
    fn variant_name(&self) -> &'static str;

    // Provided methods
    fn is_keyframes_empty(&self) -> bool { ... }
    fn has_animation(&self) -> bool { ... }
}
Expand description

Animated data container for a DataSystem.

This trait defines the contract for storing and interpolating time-varying data. The built-in AnimatedData type implements this trait.

§Associated Types

  • Data – The corresponding data system type.

§Implementation Notes

Implementations typically use TimeDataMap<T> internally to store keyframes for each data type variant.

Required Associated Types§

Source

type Data: DataSystem<Animated = Self>

The data system type that this animates.

Required Methods§

Source

fn keyframe_count(&self) -> usize

Returns the number of keyframes.

Named keyframe_count() to avoid conflict with AnimatedDataOps::len().

Source

fn times(&self) -> SmallVec<[Time; 10]>

Returns all keyframe times.

Source

fn interpolate(&self, time: Time) -> Self::Data

Interpolates the value at the given time.

Source

fn sample_at(&self, time: Time) -> Option<Self::Data>

Returns the exact sample at a time, or None if no keyframe exists.

Source

fn try_insert(&mut self, time: Time, value: Self::Data) -> Result<()>

Inserts a value at the given time, checking type compatibility.

Source

fn remove_at(&mut self, time: &Time) -> Option<Self::Data>

Removes the keyframe at the given time.

Returns the removed value if it existed. Returns None if the key was not found or if it was the last sample (the non-empty invariant prevents removing it).

Source

fn discriminant(&self) -> <Self::Data as DataSystem>::DataType

Returns the data type discriminant for this animated data.

Named discriminant() to avoid conflict with DataTypeOps::data_type().

Source

fn from_single(time: Time, value: Self::Data) -> Self

Creates animated data from a single time-value pair.

Source

fn variant_name(&self) -> &'static str

Returns the type name for this animated data.

Named variant_name() to avoid conflict with DataTypeOps::type_name().

Provided Methods§

Source

fn is_keyframes_empty(&self) -> bool

Returns true if there are no keyframes.

Source

fn has_animation(&self) -> bool

Returns true if there is more than one keyframe.

Named has_animation() to avoid conflict with AnimatedDataOps::is_animated().

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§