use std::fmt;
use thunderdome::Index;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct WidgetId(Index);
impl WidgetId {
#[inline]
pub(crate) fn new(index: Index) -> Self {
Self(index)
}
#[inline]
pub(crate) fn index(&self) -> Index {
self.0
}
}
impl fmt::Debug for WidgetId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "WidgetId({}, {})", self.0.slot(), self.0.generation())
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum TextureId {
Managed(ManagedTextureId),
User(u64),
}
impl From<ManagedTextureId> for TextureId {
fn from(value: ManagedTextureId) -> Self {
Self::Managed(value)
}
}
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct ManagedTextureId(Index);
impl ManagedTextureId {
#[inline]
pub(crate) fn new(index: Index) -> Self {
Self(index)
}
#[inline]
pub(crate) fn index(&self) -> Index {
self.0
}
}
impl fmt::Debug for ManagedTextureId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "TextureId({}, {})", self.0.slot(), self.0.generation())
}
}