ed_journals/modules/galaxy/models/
star_luminosity.rs

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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
use serde::{Deserialize, Serialize};
use std::fmt::{Display, Formatter};

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Ord, Hash, PartialOrd, Eq)]
pub enum StarLuminosity {
    O = 25,
    I = 24,
    Ia0 = 23,
    Ia = 22,
    Ib = 21,
    Iab = 20,
    II = 19,
    IIa = 18,
    IIab = 17,
    IIb = 16,
    III = 15,
    IIIa = 14,
    IIIab = 13,
    IIIb = 12,
    IV = 11,
    IVa = 10,
    IVab = 9,
    IVb = 8,
    V = 7,
    Va = 6,
    Vab = 5,
    Vb = 4,
    Vz = 3,
    VI = 2,
    VII = 1,
    #[serde(alias = "0")]
    Zero = 0,
}

impl Display for StarLuminosity {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        write!(
            f,
            "{}",
            match self {
                StarLuminosity::O => "O",
                StarLuminosity::I => "I",
                StarLuminosity::Ia0 => "Ia0",
                StarLuminosity::Ia => "Ia",
                StarLuminosity::Ib => "Ib",
                StarLuminosity::Iab => "Iab",
                StarLuminosity::II => "II",
                StarLuminosity::IIa => "IIa",
                StarLuminosity::IIab => "IIab",
                StarLuminosity::IIb => "IIb",
                StarLuminosity::III => "III",
                StarLuminosity::IIIa => "IIIa",
                StarLuminosity::IIIab => "IIIab",
                StarLuminosity::IIIb => "IIIb",
                StarLuminosity::IV => "IV",
                StarLuminosity::IVa => "IVa",
                StarLuminosity::IVab => "IVab",
                StarLuminosity::IVb => "IVb",
                StarLuminosity::V => "V",
                StarLuminosity::Va => "Va",
                StarLuminosity::Vab => "Vab",
                StarLuminosity::Vb => "Vb",
                StarLuminosity::Vz => "Vz",
                StarLuminosity::VI => "VI",
                StarLuminosity::VII => "VII",
                StarLuminosity::Zero => "Zero",
            }
        )
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_star_luminosity_comparison() {
        assert!(StarLuminosity::O > StarLuminosity::I);
        assert!(StarLuminosity::I > StarLuminosity::Ia0);
        assert!(StarLuminosity::Ia0 > StarLuminosity::Ia);
        assert!(StarLuminosity::Ia > StarLuminosity::Ib);
        assert!(StarLuminosity::Ib > StarLuminosity::Iab);
        assert!(StarLuminosity::Iab > StarLuminosity::II);
        assert!(StarLuminosity::II > StarLuminosity::IIa);
        assert!(StarLuminosity::IIa > StarLuminosity::IIab);
        assert!(StarLuminosity::IIab > StarLuminosity::IIb);
        assert!(StarLuminosity::IIb > StarLuminosity::III);
        assert!(StarLuminosity::III > StarLuminosity::IIIa);
        assert!(StarLuminosity::IIIa > StarLuminosity::IIIab);
        assert!(StarLuminosity::IIIab > StarLuminosity::IIIb);
        assert!(StarLuminosity::IIIb > StarLuminosity::IV);
        assert!(StarLuminosity::IV > StarLuminosity::IVa);
        assert!(StarLuminosity::IVa > StarLuminosity::IVab);
        assert!(StarLuminosity::IVab > StarLuminosity::IVb);
        assert!(StarLuminosity::IVb > StarLuminosity::V);
        assert!(StarLuminosity::V > StarLuminosity::Va);
        assert!(StarLuminosity::Va > StarLuminosity::Vab);
        assert!(StarLuminosity::Vab > StarLuminosity::Vb);
        assert!(StarLuminosity::Vb > StarLuminosity::Vz);
        assert!(StarLuminosity::Vz > StarLuminosity::VI);
        assert!(StarLuminosity::VI > StarLuminosity::VII);
        assert!(StarLuminosity::VII > StarLuminosity::Zero);
    }
}