use kozan_primitives::arena::RawId;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ViewId(RawId);
impl ViewId {
#[inline]
#[must_use]
pub fn from_raw(raw: RawId) -> Self {
Self(raw)
}
#[inline]
#[must_use]
pub fn raw(self) -> RawId {
self.0
}
}
impl std::fmt::Display for ViewId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "View({})", self.0)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct WindowId(u64);
static NEXT_WINDOW_ID: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(1);
impl WindowId {
pub fn next() -> Self {
Self(NEXT_WINDOW_ID.fetch_add(1, std::sync::atomic::Ordering::Relaxed))
}
#[inline]
#[must_use]
pub fn raw(self) -> u64 {
self.0
}
}
impl std::fmt::Display for WindowId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Window({})", self.0)
}
}