Skip to main content

aura_anim_iced/runtime/
handle.rs

1use std::sync::atomic::{AtomicU64, Ordering};
2
3static NEXT_HANDLE_ID: AtomicU64 = AtomicU64::new(AnimationHandle::FIRST_ID);
4
5/// Stable identifier for an animation stored in the runtime registry.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
7pub struct AnimationHandle(u64);
8
9impl AnimationHandle {
10    pub(super) const FIRST_ID: u64 = 1;
11
12    pub(super) fn new() -> Self {
13        Self(NEXT_HANDLE_ID.fetch_add(1, Ordering::Relaxed))
14    }
15
16    /// Returns the numeric handle ID.
17    #[must_use]
18    pub const fn id(self) -> u64 {
19        self.0
20    }
21}