use serde::{Deserialize, Serialize};
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum NwsUnitCode {
#[serde(rename = "nwsUnit:s")]
Second,
#[serde(rename = "nwsUnit:ns")]
Nanosecond,
#[serde(rename = "nwsUnit:MHz")]
Megahertz,
#[serde(rename = "nwsUnit:dBZ")]
DecibelZ,
#[serde(rename = "nwsUnit:dB")]
Decibel,
}
impl NwsUnitCode {
pub fn pref_label(&self) -> &'static str {
match self {
NwsUnitCode::Second => "second",
NwsUnitCode::Nanosecond => "nanosecond",
NwsUnitCode::Megahertz => "megahertz",
NwsUnitCode::DecibelZ => "decibelZ",
NwsUnitCode::Decibel => "decibel",
}
}
pub fn notation(&self) -> &'static str {
match self {
NwsUnitCode::Second => "s",
NwsUnitCode::Nanosecond => "ns",
NwsUnitCode::Megahertz => "MHz",
NwsUnitCode::DecibelZ => "dBz",
NwsUnitCode::Decibel => "dB",
}
}
pub fn alt_label(&self) -> &'static str {
match self {
NwsUnitCode::Second => "s",
NwsUnitCode::Nanosecond => "ns",
NwsUnitCode::Megahertz => "MHz",
NwsUnitCode::DecibelZ => "dBz",
NwsUnitCode::Decibel => "dB",
}
}
}