1use smallvec::SmallVec;
4use std::fmt;
5use std::sync::atomic::{AtomicU64, Ordering};
6
7#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
12pub struct FieldId(pub u32);
13
14impl fmt::Display for FieldId {
15 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16 write!(f, "{}", self.0)
17 }
18}
19
20impl From<u32> for FieldId {
21 fn from(v: u32) -> Self {
22 Self(v)
23 }
24}
25
26#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
28pub struct SpaceId(pub u32);
29
30impl fmt::Display for SpaceId {
31 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32 write!(f, "{}", self.0)
33 }
34}
35
36impl From<u32> for SpaceId {
37 fn from(v: u32) -> Self {
38 Self(v)
39 }
40}
41
42static SPACE_INSTANCE_COUNTER: AtomicU64 = AtomicU64::new(1);
44
45#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
56pub struct SpaceInstanceId(u64);
57
58impl SpaceInstanceId {
59 pub fn next() -> Self {
64 Self(SPACE_INSTANCE_COUNTER.fetch_add(1, Ordering::Relaxed))
65 }
66}
67
68impl fmt::Display for SpaceInstanceId {
69 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
70 write!(f, "{}", self.0)
71 }
72}
73
74#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
78pub struct TickId(pub u64);
79
80impl fmt::Display for TickId {
81 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
82 write!(f, "{}", self.0)
83 }
84}
85
86impl From<u64> for TickId {
87 fn from(v: u64) -> Self {
88 Self(v)
89 }
90}
91
92#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
97pub struct WorldGenerationId(pub u64);
98
99impl fmt::Display for WorldGenerationId {
100 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
101 write!(f, "{}", self.0)
102 }
103}
104
105impl From<u64> for WorldGenerationId {
106 fn from(v: u64) -> Self {
107 Self(v)
108 }
109}
110
111#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
116pub struct ParameterVersion(pub u64);
117
118impl fmt::Display for ParameterVersion {
119 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
120 write!(f, "{}", self.0)
121 }
122}
123
124impl From<u64> for ParameterVersion {
125 fn from(v: u64) -> Self {
126 Self(v)
127 }
128}
129
130#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
135pub struct ParameterKey(pub u32);
136
137impl fmt::Display for ParameterKey {
138 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
139 write!(f, "{}", self.0)
140 }
141}
142
143impl From<u32> for ParameterKey {
144 fn from(v: u32) -> Self {
145 Self(v)
146 }
147}
148
149pub type Coord = SmallVec<[i32; 4]>;