rusmpp_core/values/
ton.rs

1use rusmpp_macros::Rusmpp;
2
3/// Type of Number.
4#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Default, Rusmpp)]
5#[repr(u8)]
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 Ton {
10    #[default]
11    Unknown = 0b00000000,
12    International = 0b00000001,
13    National = 0b00000010,
14    NetworkSpecific = 0b00000011,
15    SubscriberNumber = 0b00000100,
16    Alphanumeric = 0b00000101,
17    Abbreviated = 0b00000110,
18    Other(u8),
19}
20
21impl Ton {
22    /// Create a new [`Ton`] with a value of 0.
23    ///
24    /// Equivalent to [`Ton::Unknown`].
25    pub fn null() -> Self {
26        Self::default()
27    }
28}
29
30#[cfg(test)]
31mod tests {
32    use super::*;
33
34    #[test]
35    fn encode_decode() {
36        #[cfg(feature = "alloc")]
37        crate::tests::owned::encode_decode_test_instances::<Ton>();
38        crate::tests::borrowed::encode_decode_test_instances::<Ton>();
39    }
40}