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
use serde::{Deserialize, Serialize};

#[allow(dead_code)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct RawElement {
    pub name: &'static str,
    pub appearance: Option<&'static str>,
    pub atomic_mass: f64,
    pub boil: Option<f64>,
    pub category: &'static str,
    pub color: Option<&'static str>,
    pub density: Option<f64>,
    pub melt: Option<f64>,
    pub molar_heat: Option<f64>,
    pub named_by: Option<&'static str>,
    pub number: u8,
    pub period: u8,
    pub phase: &'static str,
    pub source: &'static str,
    pub spectral_img: Option<&'static str>,
    pub summary: &'static str,
    pub symbol: &'static str,
    pub xpos: u8,
    pub ypos: u8,
    pub shells: &'static [u8],
    pub electron_configuration: &'static str,
    pub electron_configuration_semantic: &'static str,
    pub electron_affinity: Option<f64>,
    pub electronegativity_pauling: Option<f64>,
    pub ionization_energies: Vec<f64>,
    pub cpk_hex: Option<&'static str>,
}

impl RawElement {
    pub fn into_inner(self) -> InnerElement {
        InnerElement {
            name: self.name,
            symbol: self.symbol,
            description: self.summary,
            atomic_data: AtomicData {
                atomic_number: self.number,
                nucleon_number: self.atomic_mass.round() as u16,
                atomic_mass: self.atomic_mass,
            },
            state_data: StateData {
                boiling_point: self.boil,
                melting_point: self.melt,
            },
            electron_data: ElectronData {
                electron_configuration: ElectronConfiguration {},
                ionisation_energies: self.ionization_energies,
            },
        }
    }
}

#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub struct InnerElement {
    pub name: &'static str,
    pub symbol: &'static str,
    pub description: &'static str,
    pub atomic_data: AtomicData,
    pub state_data: StateData,
    pub electron_data: ElectronData,
}

#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
pub struct AtomicData {
    pub atomic_number: u8,
    pub nucleon_number: u16,
    pub atomic_mass: f64,
}

#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
pub struct StateData {
    pub boiling_point: Option<f64>,
    pub melting_point: Option<f64>,
}

#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub struct ElectronData {
    pub electron_configuration: ElectronConfiguration,
    pub ionisation_energies: Vec<f64>,
}

#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
pub struct ElectronConfiguration {}