1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
//! Core traits for generic data systems.
//!
//! This module defines the foundational traits that allow you to define your
//! own data type systems. By implementing these traits, you can replace the
//! built-in [`Data`](crate::Data) and [`AnimatedData`](crate::AnimatedData)
//! types entirely, or extend them with custom types.
//!
//! # Overview
//!
//! The trait hierarchy is:
//! - [`Interpolatable`] -- Types that can be interpolated over time.
//! - [`DataSystem`] -- A complete enum of data variants (like [`Data`](crate::Data)).
//! - [`AnimatedDataSystem`] -- Container for animated data (like [`AnimatedData`](crate::AnimatedData)).
//!
//! # Example
//!
//! ```ignore
//! use token_value_map::{DataSystem, AnimatedDataSystem, GenericValue};
//!
//! // Define your own data enum.
//! #[derive(Clone, Debug, PartialEq, Eq, Hash)]
//! pub enum MyData {
//! Float(f64),
//! Quat(MyQuaternion),
//! }
//!
//! // Implement the traits.
//! impl DataSystem for MyData { /* ... */ }
//!
//! // Use with generic types.
//! type MyValue = GenericValue<MyData>;
//! ```
use SmallVec;
use ;
use crate::;
/// Trait for converting data types to f32 for curve editing.
///
/// Implement this trait on your data enum to enable egui-keyframe integration
/// with [`GenericValue`](crate::GenericValue). Return `None` for types that
/// cannot be displayed as scalar curves (e.g., strings, colors, transforms).
///
/// # Example
///
/// ```ignore
/// impl ToF32 for MyData {
/// fn to_f32(&self) -> Option<f32> {
/// match self {
/// MyData::Float(f) => Some(*f),
/// MyData::Vec3(_) => None, // Can't display as single curve.
/// }
/// }
/// }
/// ```
/// Marker trait for types that support time-based interpolation.
///
/// Types implementing this trait can be used with [`TimeDataMap`](crate::TimeDataMap)
/// for automatic interpolation between keyframes.
///
/// # Required Bounds
///
/// - `Clone` -- Values must be cloneable for interpolation.
/// - `Add`, `Sub` -- Vector arithmetic for blending.
/// - `Mul<f32>`, `Mul<f64>` -- Scalar multiplication for weighting.
/// - `Div<f32>`, `Div<f64>` -- Scalar division for normalization.
/// - `PartialEq` -- Equality comparison for optimization.
/// - `Send + Sync + 'static` -- Thread safety for parallel operations.
// Blanket implementation for any type meeting the bounds.
/// A complete data type system.
///
/// This trait defines the contract for a "data enum" -- a type that can hold
/// any of several different value types (scalars, vectors, matrices, etc.).
///
/// The built-in [`Data`](crate::Data) type implements this trait. You can
/// define your own enums and implement this trait to create custom type systems.
///
/// # Associated Types
///
/// - `Animated` -- The corresponding animated data container type.
/// - `DataType` -- A discriminant enum for identifying variants.
///
/// # Example
///
/// ```ignore
/// impl DataSystem for MyData {
/// type Animated = MyAnimatedData;
/// type DataType = MyDataType;
///
/// fn data_type(&self) -> MyDataType {
/// match self {
/// MyData::Float(_) => MyDataType::Float,
/// MyData::Quat(_) => MyDataType::Quat,
/// }
/// }
///
/// fn type_name(&self) -> &'static str {
/// match self {
/// MyData::Float(_) => "float",
/// MyData::Quat(_) => "quat",
/// }
/// }
/// }
/// ```
/// Animated data container for a [`DataSystem`].
///
/// This trait defines the contract for storing and interpolating time-varying
/// data. The built-in [`AnimatedData`](crate::AnimatedData) type implements
/// this trait.
///
/// # Associated Types
///
/// - `Data` -- The corresponding data system type.
///
/// # Implementation Notes
///
/// Implementations typically use [`TimeDataMap<T>`](crate::TimeDataMap) internally
/// to store keyframes for each data type variant.