1use serde::{Deserialize, Serialize};
4
5macro_rules! id_type {
6 ($(#[$m:meta])* $name:ident) => {
7 $(#[$m])*
8 #[derive(
9 Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize,
10 )]
11 pub struct $name(pub u32);
12 };
13}
14
15id_type!(
16 CategoryId
18);
19id_type!(
20 ItemId
22);
23id_type!(
24 MeasureId
26);
27id_type!(
28 ViewId
30);
31id_type!(
32 ScenarioId
34);
35
36#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
39pub struct Name(pub String);
40
41impl From<&str> for Name {
42 fn from(s: &str) -> Self {
43 Name(s.to_string())
44 }
45}
46
47impl std::fmt::Display for Name {
48 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
49 f.write_str(&self.0)
50 }
51}