weavatrix_graph/topology/
index.rs1use serde::{Deserialize, Serialize};
2
3macro_rules! define_index {
4 ($name:ident) => {
5 #[derive(
6 Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize,
7 )]
8 #[serde(transparent)]
9 pub struct $name(u32);
10
11 impl $name {
12 #[must_use]
13 pub const fn new(index: u32) -> Self {
14 Self(index)
15 }
16
17 #[must_use]
18 pub const fn get(self) -> u32 {
19 self.0
20 }
21
22 #[must_use]
23 pub const fn index(self) -> usize {
24 self.0 as usize
25 }
26 }
27 };
28}
29
30define_index!(NodeIndex);
31define_index!(EdgeIndex);