use std::fmt;
macro_rules! define_id {
($name:ident, $label:literal) => {
#[doc = concat!("A stable identifier for an avatar ", $label, ".")]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct $name(u32);
impl $name {
pub const fn from_index(index: usize) -> Self {
Self(index as u32)
}
pub const fn index(self) -> usize {
self.0 as usize
}
}
impl fmt::Display for $name {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(formatter)
}
}
};
}
define_id!(NodeId, "node");
define_id!(PrimitiveId, "render primitive");
define_id!(MaterialId, "material");
define_id!(TextureId, "texture");
define_id!(ImageId, "image");
define_id!(SkinId, "skin");