1use kozan_primitives::arena::RawId;
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
12pub struct ViewId(RawId);
13
14impl ViewId {
15 #[inline]
17 #[must_use]
18 pub fn from_raw(raw: RawId) -> Self {
19 Self(raw)
20 }
21
22 #[inline]
23 #[must_use]
24 pub fn raw(self) -> RawId {
25 self.0
26 }
27}
28
29impl std::fmt::Display for ViewId {
30 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31 write!(f, "View({})", self.0)
32 }
33}
34
35#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
40pub struct WindowId(u64);
41
42static NEXT_WINDOW_ID: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(1);
43
44impl WindowId {
45 pub fn next() -> Self {
47 Self(NEXT_WINDOW_ID.fetch_add(1, std::sync::atomic::Ordering::Relaxed))
48 }
49
50 #[inline]
52 #[must_use]
53 pub fn raw(self) -> u64 {
54 self.0
55 }
56}
57
58impl std::fmt::Display for WindowId {
59 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
60 write!(f, "Window({})", self.0)
61 }
62}