Skip to main content

KeyDataMap

Struct KeyDataMap 

Source
pub struct KeyDataMap<K, V> {
    pub values: BTreeMap1<K, V>,
}
Expand description

A generic key-value data map with interpolation support.

Stores key-value pairs in a BTreeMap1 for efficient ordered queries and supports various interpolation methods. The map is guaranteed to be non-empty at the type level.

When the interpolation feature is enabled, each value can have an associated interpolation specification for animation curves.

Use the type alias TimeDataMap<V> for time-keyed maps (the common case), or use KeyDataMap<Position, V> for curve-domain maps.

Fields§

§values: BTreeMap1<K, V>

The key-value pairs with optional interpolation keys.

Guaranteed non-empty by BTreeMap1.

Implementations§

Source§

impl<K: Ord, V> KeyDataMap<K, V>

Source

pub fn iter(&self) -> impl Iterator<Item = (&K, &V)>

Get an iterator over key-value pairs.

Source

pub fn is_empty(&self) -> bool

Always returns falseBTreeMap1 guarantees at least one entry.

Source

pub fn len(&self) -> usize

Get the number of entries.

Source

pub fn remove(&mut self, key: &K) -> Result<Option<V>>

Remove a sample at the given key.

Returns Ok(Some(value)) if the key existed and was removed, Ok(None) if the key was not found, or Err(LastSample) if removing the key would empty the map.

Source§

impl<K: Ord, V> KeyDataMap<K, V>

Source

pub fn from_single(key: K, value: V) -> Self

Create a map with a single key-value pair.

Source§

impl<K: Ord, V> KeyDataMap<K, V>

Source

pub fn insert(&mut self, key: K, value: V)

Insert a value at the given key.

Source

pub fn get(&self, key: &K) -> Option<&V>

Get a value at the exact key.

Source§

impl<K, V> KeyDataMap<K, V>
where K: Ord + Copy + Into<f32>, V: Clone + Add<Output = V> + Mul<f32, Output = V> + Sub<Output = V>,

Source

pub fn interpolate(&self, key: K) -> V

Source§

impl<K: Ord + Copy + Into<f32>, V> KeyDataMap<K, V>

Source

pub fn closest_sample(&self, key: K) -> &V

Source

pub fn sample_at(&self, key: K) -> Option<&V>

Sample value at exact key (no interpolation).

Source

pub fn sample_at_or_before(&self, key: K) -> Option<&V>

Get the value at or before the given key.

Source

pub fn sample_at_or_after(&self, key: K) -> Option<&V>

Get the value at or after the given key.

Source

pub fn sample_surrounding<const N: usize>( &self, key: K, ) -> SmallVec<[(K, &V); N]>

Get surrounding samples for interpolation.

Returns up to N samples centered around the given key for use in interpolation algorithms.

Trait Implementations§

Source§

impl<K, V> AsRef<BTreeMap<K, V>> for KeyDataMap<K, V>

Available on non-crate feature interpolation only.
Source§

fn as_ref(&self) -> &BTreeMap<K, V>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<K: Clone, V: Clone> Clone for KeyDataMap<K, V>

Source§

fn clone(&self) -> KeyDataMap<K, V>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: Ord, V> DataTypeOps for KeyDataMap<K, V>
where V: DataTypeOps,

Available on crate feature builtin-types only.
Source§

fn data_type(&self) -> DataType

Returns the DataType variant for this value.
Source§

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

Returns a string name for this data type.
Source§

impl<K: Debug, V: Debug> Debug for KeyDataMap<K, V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<KeyDataMap<Tick, Boolean>> for AnimatedData

Source§

fn from(v: TimeDataMap<Boolean>) -> AnimatedData

Converts to this type from the input type.
Source§

impl From<KeyDataMap<Tick, BooleanVec>> for AnimatedData

Source§

fn from(v: TimeDataMap<BooleanVec>) -> AnimatedData

Converts to this type from the input type.
Source§

impl From<KeyDataMap<Tick, Color>> for AnimatedData

Source§

fn from(v: TimeDataMap<Color>) -> AnimatedData

Converts to this type from the input type.
Source§

impl From<KeyDataMap<Tick, ColorCurve>> for AnimatedData

Available on crate feature curves only.
Source§

fn from(v: TimeDataMap<ColorCurve>) -> AnimatedData

Converts to this type from the input type.
Source§

impl From<KeyDataMap<Tick, ColorVec>> for AnimatedData

Source§

fn from(v: TimeDataMap<ColorVec>) -> AnimatedData

Converts to this type from the input type.
Source§

impl From<KeyDataMap<Tick, Integer>> for AnimatedData

Source§

fn from(v: TimeDataMap<Integer>) -> AnimatedData

Converts to this type from the input type.
Source§

impl From<KeyDataMap<Tick, IntegerVec>> for AnimatedData

Source§

fn from(v: TimeDataMap<IntegerVec>) -> AnimatedData

Converts to this type from the input type.
Source§

impl From<KeyDataMap<Tick, Matrix3>> for AnimatedData

Available on crate feature matrix3 only.
Source§

fn from(v: TimeDataMap<Matrix3>) -> AnimatedData

Converts to this type from the input type.
Source§

impl From<KeyDataMap<Tick, Matrix3Vec>> for AnimatedData

Available on crate features matrix3 and vec_variants only.
Source§

fn from(v: TimeDataMap<Matrix3Vec>) -> AnimatedData

Converts to this type from the input type.
Source§

impl From<KeyDataMap<Tick, Real>> for AnimatedData

Source§

fn from(v: TimeDataMap<Real>) -> AnimatedData

Converts to this type from the input type.
Source§

impl From<KeyDataMap<Tick, RealCurve>> for AnimatedData

Available on crate feature curves only.
Source§

fn from(v: TimeDataMap<RealCurve>) -> AnimatedData

Converts to this type from the input type.
Source§

impl From<KeyDataMap<Tick, RealVec>> for AnimatedData

Source§

fn from(v: TimeDataMap<RealVec>) -> AnimatedData

Converts to this type from the input type.
Source§

impl From<KeyDataMap<Tick, String>> for AnimatedData

Source§

fn from(v: TimeDataMap<String>) -> AnimatedData

Converts to this type from the input type.
Source§

impl From<KeyDataMap<Tick, StringVec>> for AnimatedData

Source§

fn from(v: TimeDataMap<StringVec>) -> AnimatedData

Converts to this type from the input type.
Source§

impl From<KeyDataMap<Tick, Vector2>> for AnimatedData

Available on crate feature vector2 only.
Source§

fn from(v: TimeDataMap<Vector2>) -> AnimatedData

Converts to this type from the input type.
Source§

impl From<KeyDataMap<Tick, Vector2Vec>> for AnimatedData

Available on crate features vector2 and vec_variants only.
Source§

fn from(v: TimeDataMap<Vector2Vec>) -> AnimatedData

Converts to this type from the input type.
Source§

impl<K: Ord, V> From<NonEmpty<BTreeMap<K, V>>> for KeyDataMap<K, V>

Available on non-crate feature interpolation only.
Source§

fn from(values: BTreeMap1<K, V>) -> Self

Converts to this type from the input type.
Source§

impl<K: Ord, V, U> FromIterator<(K, U)> for KeyDataMap<K, V>
where U: Into<V>,

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = (K, U)>,

Creates a value from an iterator. Read more
Source§

impl<K: Hash, V: Hash> Hash for KeyDataMap<K, V>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<K: PartialEq, V: PartialEq> PartialEq for KeyDataMap<K, V>

Source§

fn eq(&self, other: &KeyDataMap<K, V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V> TimeDataMapControl<V> for KeyDataMap<Time, V>

Source§

fn len(&self) -> usize

Returns the number of time samples.
Source§

fn is_empty(&self) -> bool

Returns true if there are no time samples.
Source§

fn is_animated(&self) -> bool

Returns true if there is more than one time sample.
Source§

impl<K: Ord, V> TryFrom<BTreeMap<K, V>> for KeyDataMap<K, V>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(values: BTreeMap<K, V>) -> Result<Self>

Performs the conversion.
Source§

impl TryInto<KeyDataMap<Tick, Boolean>> for AnimatedData

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_into( self, ) -> Result<TimeDataMap<Boolean>, <Self as TryInto<TimeDataMap<Boolean>>>::Error>

Performs the conversion.
Source§

impl TryInto<KeyDataMap<Tick, BooleanVec>> for AnimatedData

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_into( self, ) -> Result<TimeDataMap<BooleanVec>, <Self as TryInto<TimeDataMap<BooleanVec>>>::Error>

Performs the conversion.
Source§

impl TryInto<KeyDataMap<Tick, Color>> for AnimatedData

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_into( self, ) -> Result<TimeDataMap<Color>, <Self as TryInto<TimeDataMap<Color>>>::Error>

Performs the conversion.
Source§

impl TryInto<KeyDataMap<Tick, ColorCurve>> for AnimatedData

Available on crate feature curves only.
Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_into( self, ) -> Result<TimeDataMap<ColorCurve>, <Self as TryInto<TimeDataMap<ColorCurve>>>::Error>

Performs the conversion.
Source§

impl TryInto<KeyDataMap<Tick, ColorVec>> for AnimatedData

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_into( self, ) -> Result<TimeDataMap<ColorVec>, <Self as TryInto<TimeDataMap<ColorVec>>>::Error>

Performs the conversion.
Source§

impl TryInto<KeyDataMap<Tick, Integer>> for AnimatedData

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_into( self, ) -> Result<TimeDataMap<Integer>, <Self as TryInto<TimeDataMap<Integer>>>::Error>

Performs the conversion.
Source§

impl TryInto<KeyDataMap<Tick, IntegerVec>> for AnimatedData

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_into( self, ) -> Result<TimeDataMap<IntegerVec>, <Self as TryInto<TimeDataMap<IntegerVec>>>::Error>

Performs the conversion.
Source§

impl TryInto<KeyDataMap<Tick, Matrix3>> for AnimatedData

Available on crate feature matrix3 only.
Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_into( self, ) -> Result<TimeDataMap<Matrix3>, <Self as TryInto<TimeDataMap<Matrix3>>>::Error>

Performs the conversion.
Source§

impl TryInto<KeyDataMap<Tick, Matrix3Vec>> for AnimatedData

Available on crate features matrix3 and vec_variants only.
Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_into( self, ) -> Result<TimeDataMap<Matrix3Vec>, <Self as TryInto<TimeDataMap<Matrix3Vec>>>::Error>

Performs the conversion.
Source§

impl TryInto<KeyDataMap<Tick, Real>> for AnimatedData

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_into( self, ) -> Result<TimeDataMap<Real>, <Self as TryInto<TimeDataMap<Real>>>::Error>

Performs the conversion.
Source§

impl TryInto<KeyDataMap<Tick, RealCurve>> for AnimatedData

Available on crate feature curves only.
Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_into( self, ) -> Result<TimeDataMap<RealCurve>, <Self as TryInto<TimeDataMap<RealCurve>>>::Error>

Performs the conversion.
Source§

impl TryInto<KeyDataMap<Tick, RealVec>> for AnimatedData

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_into( self, ) -> Result<TimeDataMap<RealVec>, <Self as TryInto<TimeDataMap<RealVec>>>::Error>

Performs the conversion.
Source§

impl TryInto<KeyDataMap<Tick, String>> for AnimatedData

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_into( self, ) -> Result<TimeDataMap<String>, <Self as TryInto<TimeDataMap<String>>>::Error>

Performs the conversion.
Source§

impl TryInto<KeyDataMap<Tick, StringVec>> for AnimatedData

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_into( self, ) -> Result<TimeDataMap<StringVec>, <Self as TryInto<TimeDataMap<StringVec>>>::Error>

Performs the conversion.
Source§

impl TryInto<KeyDataMap<Tick, Vector2>> for AnimatedData

Available on crate feature vector2 only.
Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_into( self, ) -> Result<TimeDataMap<Vector2>, <Self as TryInto<TimeDataMap<Vector2>>>::Error>

Performs the conversion.
Source§

impl TryInto<KeyDataMap<Tick, Vector2Vec>> for AnimatedData

Available on crate features vector2 and vec_variants only.
Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_into( self, ) -> Result<TimeDataMap<Vector2Vec>, <Self as TryInto<TimeDataMap<Vector2Vec>>>::Error>

Performs the conversion.
Source§

impl<K: Eq, V: Eq> Eq for KeyDataMap<K, V>

Source§

impl<K, V> StructuralPartialEq for KeyDataMap<K, V>

Auto Trait Implementations§

§

impl<K, V> Freeze for KeyDataMap<K, V>

§

impl<K, V> RefUnwindSafe for KeyDataMap<K, V>

§

impl<K, V> Send for KeyDataMap<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for KeyDataMap<K, V>
where K: Sync, V: Sync,

§

impl<K, V> Unpin for KeyDataMap<K, V>

§

impl<K, V> UnsafeUnpin for KeyDataMap<K, V>

§

impl<K, V> UnwindSafe for KeyDataMap<K, V>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.