castep_param_io/param/units/
volume_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 volume will be reported.
11/// # Example
12/// ` VOLUME_UNIT : nm**3`
13pub enum VolumeUnit {
14    Bohr3,
15    Meter3,
16    Centimeter3,
17    Nanometer3,
18    #[default]
19    Ang3,
20}
21
22impl Display for VolumeUnit {
23    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
24        match self {
25            VolumeUnit::Bohr3 => f.write_str("bohr**3"),
26            VolumeUnit::Meter3 => f.write_str("m**3"),
27            VolumeUnit::Centimeter3 => f.write_str("cm**3"),
28            VolumeUnit::Nanometer3 => f.write_str("nm**3"),
29            VolumeUnit::Ang3 => f.write_str("ang**3"),
30        }
31    }
32}
33
34impl KeywordDisplay for VolumeUnit {
35    fn field(&self) -> String {
36        "VOLUME_UNIT".to_string()
37    }
38}