rusmpp_core/values/unsuccess_sme/
borrowed.rs

1use rusmpp_macros::Rusmpp;
2
3use crate::{
4    CommandStatus,
5    types::borrowed::COctetString,
6    values::{npi::Npi, ton::Ton},
7};
8
9#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Rusmpp)]
10#[rusmpp(decode = borrowed)]
11#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
12#[cfg_attr(feature = "serde", derive(::serde::Serialize))]
13pub struct UnsuccessSme<'a> {
14    /// Type of number for destination.
15    pub dest_addr_ton: Ton,
16    /// Numbering Plan Indicator for destination.
17    pub dest_addr_npi: Npi,
18    /// Destination Address of SME.
19    pub destination_addr: COctetString<'a, 1, 21>,
20    /// Indicates the success or failure of the [`SubmitMulti`](type@crate::pdus::borrowed::SubmitMulti) request to this SME address.
21    pub error_status_code: CommandStatus,
22}
23
24impl Default for UnsuccessSme<'_> {
25    fn default() -> Self {
26        Self {
27            dest_addr_ton: Ton::default(),
28            dest_addr_npi: Npi::default(),
29            destination_addr: COctetString::default(),
30            error_status_code: CommandStatus::EsmeRunknownerr,
31        }
32    }
33}
34
35impl<'a> UnsuccessSme<'a> {
36    pub fn new(
37        dest_addr_ton: Ton,
38        dest_addr_npi: Npi,
39        destination_addr: COctetString<'a, 1, 21>,
40        error_status_code: CommandStatus,
41    ) -> Self {
42        Self {
43            dest_addr_ton,
44            dest_addr_npi,
45            destination_addr,
46            error_status_code,
47        }
48    }
49}
50
51#[cfg(test)]
52mod tests {
53    use super::*;
54
55    #[test]
56    fn encode_decode() {
57        crate::tests::borrowed::encode_decode_test_instances::<UnsuccessSme>();
58    }
59}