rusmpp_core/values/
npi.rs

1use rusmpp_macros::Rusmpp;
2
3/// Numeric Plan Indicator.
4#[repr(u8)]
5#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Default, Rusmpp)]
6#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
7#[cfg_attr(feature = "serde", derive(::serde::Serialize))]
8#[cfg_attr(feature = "serde-deserialize-unchecked", derive(::serde::Deserialize))]
9pub enum Npi {
10    #[default]
11    Unknown = 0b00000000,
12    Isdn = 0b00000001,
13    Data = 0b00000011,
14    Telex = 0b00000100,
15    LandMobile = 0b00000110,
16    National = 0b00001000,
17    Private = 0b00001001,
18    Ermes = 0b00001010,
19    Internet = 0b00001110,
20    WapClientId = 0b00010010,
21    Other(u8),
22}
23
24impl Npi {
25    /// Create a new [`Npi`] with a value of 0.
26    ///
27    /// Equivalent to [`Npi::Unknown`].
28    pub fn null() -> Self {
29        Self::default()
30    }
31}
32
33#[cfg(test)]
34mod tests {
35    use super::*;
36
37    #[test]
38    fn encode_decode() {
39        #[cfg(feature = "alloc")]
40        crate::tests::owned::encode_decode_test_instances::<Npi>();
41        crate::tests::borrowed::encode_decode_test_instances::<Npi>();
42    }
43}