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§
Sourcetype Data: DataSystem<Animated = Self>
type Data: DataSystem<Animated = Self>
The data system type that this animates.
Required Methods§
Sourcefn keyframe_count(&self) -> usize
fn keyframe_count(&self) -> usize
Returns the number of keyframes.
Named keyframe_count() to avoid conflict with AnimatedDataOps::len().
Sourcefn interpolate(&self, time: Time) -> Self::Data
fn interpolate(&self, time: Time) -> Self::Data
Interpolates the value at the given time.
Sourcefn sample_at(&self, time: Time) -> Option<Self::Data>
fn sample_at(&self, time: Time) -> Option<Self::Data>
Returns the exact sample at a time, or None if no keyframe exists.
Sourcefn try_insert(&mut self, time: Time, value: Self::Data) -> Result<()>
fn try_insert(&mut self, time: Time, value: Self::Data) -> Result<()>
Inserts a value at the given time, checking type compatibility.
Sourcefn remove_at(&mut self, time: &Time) -> Option<Self::Data>
fn remove_at(&mut self, time: &Time) -> Option<Self::Data>
Removes the keyframe at the given time.
Returns the removed value if it existed.
Sourcefn discriminant(&self) -> <Self::Data as DataSystem>::DataType
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().
Sourcefn from_single(time: Time, value: Self::Data) -> Self
fn from_single(time: Time, value: Self::Data) -> Self
Creates animated data from a single time-value pair.
Sourcefn variant_name(&self) -> &'static str
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§
Sourcefn is_keyframes_empty(&self) -> bool
fn is_keyframes_empty(&self) -> bool
Returns true if there are no keyframes.
Sourcefn has_animation(&self) -> bool
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.