Skip to main content

re_core/
id.rs

1use serde::{Deserialize, Serialize};
2use std::fmt;
3
4macro_rules! id_type {
5    ($name:ident, $prefix:literal) => {
6        #[derive(
7            Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Debug,
8        )]
9        #[serde(transparent)]
10        pub struct $name(pub u32);
11
12        impl fmt::Display for $name {
13            fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
14                write!(f, "{}{}", $prefix, self.0)
15            }
16        }
17    };
18}
19
20id_type!(NodeId, "n");
21id_type!(MeshId, "m");
22id_type!(SkeletonId, "s");
23id_type!(AnimationId, "a");
24id_type!(MaterialId, "mat");
25id_type!(TileSetId, "ts");
26id_type!(TileMapId, "tm");