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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use codec::{Decode, Encode};
use sp_runtime::RuntimeDebug;
use sp_std::prelude::*;
#[derive(PartialEq, Eq, Default, Copy, Clone, Encode, Decode, RuntimeDebug)]
pub struct UUID(u32);
#[derive(PartialEq, Eq, Default, Copy, Clone, Encode, Decode, RuntimeDebug)]
pub struct UUID2(u32, u32);
impl UUID2 {
pub fn new(one: u32, two: u32) -> UUID2 {
UUID2(one, two)
}
pub fn one(&self) -> u32 {
self.0
}
pub fn two(&self) -> u32 {
self.1
}
}
#[derive(PartialEq, Eq, Default, Copy, Clone, Encode, Decode, RuntimeDebug)]
pub struct UUID3(u32, u32, u32);
impl UUID3 {
pub fn new(one: u32, two: u32, three: u32) -> UUID3 {
UUID3(one, two, three)
}
pub fn one_two(&self) -> UUID2 {
UUID2::new(self.0, self.1)
}
pub fn one(&self) -> u32 {
self.0
}
pub fn two(&self) -> u32 {
self.1
}
pub fn three(&self) -> u32 {
self.2
}
}
#[derive(PartialEq, Eq, Default, Copy, Clone, Encode, Decode, RuntimeDebug)]
pub struct UUID4(u32, u32, u32, u32);
impl UUID4 {
pub fn new(one: u32, two: u32, three: u32, four: u32) -> UUID4 {
UUID4(one, two, three, four)
}
pub fn one_two_three(&self) -> UUID3 {
UUID3::new(self.0, self.1, self.2)
}
pub fn one_two(&self) -> UUID2 {
UUID2::new(self.0, self.1)
}
pub fn one(&self) -> u32 {
self.0
}
pub fn two(&self) -> u32 {
self.1
}
pub fn three(&self) -> u32 {
self.2
}
pub fn four(&self) -> u32 {
self.3
}
}