Skip to main content

periodic_table_rs/element/
mod.rs

1pub mod names;
2pub use names::Name;
3
4pub mod symbols;
5pub use symbols::Symbol;
6
7use strum_macros::AsRefStr;
8
9#[derive(Debug)]
10pub struct Element {
11    pub atomic_number: u8,
12    pub symbol: Symbol,
13    pub name: Name,
14    pub atomic_mass: f64,
15    pub cpk_hex_color: Option<Color>,
16    pub electron_configuration: &'static [ElectronConfigurationPart],
17    pub electronegativity: Option<f64>,
18    pub atomic_radius: Option<u16>,
19    pub ionization_energy: Option<f64>,
20    pub electron_affinity: Option<f64>,
21    pub oxidation_states: Option<&'static [i8]>,
22    pub standard_state: MatterState,
23    pub melting_point: Option<f64>,
24    pub boiling_point: Option<f64>,
25    pub density: Option<f64>,
26    pub group_block: GroupBlock,
27    pub year_discovered: YearDiscovered,
28}
29
30#[derive(Debug, AsRefStr)]
31pub enum MatterState {
32    Gas,
33    Solid,
34    Liquid,
35}
36
37#[derive(Debug, AsRefStr)]
38pub enum GroupBlock {
39    Nonmetal,
40    NobleGas,
41    AlkaliMetal,
42    AlkalineEarthMetal,
43    Metalloid,
44    Halogen,
45    PostTransitionMetal,
46    TransitionMetal,
47    Lanthanide,
48    Actinide,
49}
50
51#[derive(Debug)]
52pub struct Color {
53    pub red: u8,
54    pub green: u8,
55    pub blue: u8,
56}
57
58#[derive(Debug, AsRefStr)]
59pub enum Orbital {
60    S,
61    P,
62    D,
63    F,
64}
65
66#[derive(Debug)]
67pub struct ElectronConfigurationPart {
68    pub energy_level: u8,
69    pub orbital: Orbital,
70    pub electrons: u8,
71}
72
73#[derive(Debug, AsRefStr)]
74pub enum YearDiscovered {
75    Year(u16),
76    Ancient,
77}