grib/codetables/
external.rs

1use num_enum::{IntoPrimitive, TryFromPrimitive};
2
3use crate::Parameter;
4
5#[derive(Debug, Eq, PartialEq, Clone, TryFromPrimitive, IntoPrimitive)]
6#[repr(u32)]
7/// Parameter code used in NCEP.
8pub enum NCEP {
9    /// Pressure.
10    PRES = 0x_00_03_00,
11    /// Pressure reduced to MSL.
12    PRMSL = 0x_00_03_01,
13    /// Geopotential Height.
14    HGT = 0x_00_03_05,
15}
16
17impl TryFrom<&Parameter> for NCEP {
18    type Error = &'static str;
19
20    fn try_from(value: &Parameter) -> Result<Self, Self::Error> {
21        let code = value.as_u32();
22        Self::try_from_primitive(code).map_err(|_| "code not found")
23    }
24}