1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use std::fmt;
pub trait NaiaKey<Impl = Self>: Eq + PartialEq + Clone + Copy + fmt::Display {
fn from_u16(k: u16) -> Impl;
fn to_u16(&self) -> u16;
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
pub struct LocalEntity(u16);
impl NaiaKey for LocalEntity {
fn from_u16(k: u16) -> Self {
LocalEntity(k)
}
fn to_u16(&self) -> u16 {
self.0
}
}
impl fmt::Display for LocalEntity {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0)
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
pub struct LocalComponentKey(u16);
impl NaiaKey for LocalComponentKey {
fn from_u16(k: u16) -> Self {
LocalComponentKey(k)
}
fn to_u16(&self) -> u16 {
self.0
}
}
impl fmt::Display for LocalComponentKey {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0)
}
}