castep_param_io/param/units/
mass_unit.rs

1use std::fmt::Display;
2
3use serde::{Deserialize, Serialize};
4
5use crate::param::KeywordDisplay;
6
7#[derive(
8    Debug, Clone, Copy, Hash, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Default,
9)]
10/// This keyword specifies the units in which masses will be reported.
11/// # Example
12/// `MASS_UNIT : kg`
13pub enum MassUnit {
14    ElectronMass,
15    #[default]
16    AtomicMassUnit,
17    Kilogram,
18    Gram,
19}
20
21impl Display for MassUnit {
22    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23        match self {
24            MassUnit::ElectronMass => f.write_str("me"),
25            MassUnit::AtomicMassUnit => f.write_str("amu"),
26            MassUnit::Kilogram => f.write_str("kg"),
27            MassUnit::Gram => f.write_str("g"),
28        }
29    }
30}
31
32impl KeywordDisplay for MassUnit {
33    fn field(&self) -> String {
34        "MASS_UNIT".to_string()
35    }
36}