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
#[derive(PartialEq, Clone, Copy, Debug)]
pub enum IotaUnits {
Iota,
KiloIota,
MegaIota,
GigaIota,
TeraIota,
PetaIota,
}
impl IotaUnits {
pub fn unit(self) -> &'static str {
match self {
IotaUnits::Iota => "i",
IotaUnits::KiloIota => "Ki",
IotaUnits::MegaIota => "Mi",
IotaUnits::GigaIota => "Gi",
IotaUnits::TeraIota => "Ti",
IotaUnits::PetaIota => "Pi",
}
}
pub fn value(self) -> u8 {
match self {
IotaUnits::Iota => 0,
IotaUnits::KiloIota => 3,
IotaUnits::MegaIota => 6,
IotaUnits::GigaIota => 9,
IotaUnits::TeraIota => 12,
IotaUnits::PetaIota => 15,
}
}
}