Skip to main content

aura_anim_iced/runtime/
registration.rs

1use super::{AnimationHandle, AnimationPlaybackState};
2use crate::{
3    AnimationTargetId, property::PropertySnapshot, runtime::entry::ActiveAnimation,
4    timing::Duration,
5};
6
7/// Output produced when an animation is registered with the runtime.
8#[derive(Debug, Clone, PartialEq)]
9pub struct AnimationRegistration {
10    target: AnimationTargetId,
11    handle: AnimationHandle,
12    state: AnimationPlaybackState,
13    properties: Option<PropertySnapshot>,
14    completed_at: Option<Duration>,
15}
16
17impl AnimationRegistration {
18    pub(super) fn from_entry(entry: &ActiveAnimation) -> Self {
19        Self {
20            target: entry.target(),
21            handle: entry.handle(),
22            state: entry.state(),
23            properties: entry.last_snapshot().cloned(),
24            completed_at: entry.completed_at(),
25        }
26    }
27
28    /// Returns the registered animation handle.
29    #[must_use]
30    pub const fn handle(&self) -> AnimationHandle {
31        self.handle
32    }
33
34    /// Returns the initial playback state.
35    #[must_use]
36    pub const fn state(&self) -> AnimationPlaybackState {
37        self.state
38    }
39
40    /// Returns the initial property snapshot produced during registration.
41    #[must_use]
42    pub const fn properties(&self) -> Option<&PropertySnapshot> {
43        self.properties.as_ref()
44    }
45
46    /// Returns the completion timestamp for animations completed at registration.
47    #[must_use]
48    pub const fn completed_at(&self) -> Option<Duration> {
49        self.completed_at
50    }
51}