1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
use rusmpp_macros::Rusmpp;
use crate::{pdus::borrowed::Pdu, types::borrowed::COctetString, values::*};
/// This command is issued by the ESME to query the status of a previously submitted short
/// message.
/// The matching mechanism is based on the MC assigned message_id and source address.
/// Where the original submit_sm, data_sm or submit_multi ‘source address’ was defaulted to
/// NULL, then the source address in the query_sm command should also be set to NULL.
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Default, Rusmpp)]
#[rusmpp(decode = borrowed, test = skip)]
#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
#[cfg_attr(feature = "serde", derive(::serde::Serialize))]
pub struct QuerySm<'a> {
/// Message ID of the message whose state
/// is to be queried. This must be the MC
/// assigned Message ID allocated to the
/// original short message when submitted
/// to the MC by the submit_sm, data_sm or
/// submit_multi command, and returned in
/// the response PDU by the MC.
pub message_id: COctetString<'a, 1, 65>,
/// Type of Number of message originator.
/// This is used for verification purposes,
/// and must match that supplied in the
/// original request PDU (e.g. submit_sm).
///
/// If not known, set to NULL.
pub source_addr_ton: Ton,
/// Numbering Plan Identity of message
/// originator.
/// This is used for verification purposes,
/// and must match that supplied in the
/// original message submission request
/// PDU.
///
/// If not known, set to NULL.
pub source_addr_npi: Npi,
/// Address of message originator.
/// This is used for verification purposes,
/// and must match that supplied in the
/// original request PDU (e.g. submit_sm).
///
/// If not known, set to NULL.
pub source_addr: COctetString<'a, 1, 21>,
}
impl<'a> QuerySm<'a> {
pub fn new(
message_id: COctetString<'a, 1, 65>,
source_addr_ton: Ton,
source_addr_npi: Npi,
source_addr: COctetString<'a, 1, 21>,
) -> Self {
Self {
message_id,
source_addr_ton,
source_addr_npi,
source_addr,
}
}
pub fn builder() -> QuerySmBuilder<'a> {
QuerySmBuilder::new()
}
}
impl<'a, const N: usize> From<QuerySm<'a>> for Pdu<'a, N> {
fn from(value: QuerySm<'a>) -> Self {
Self::QuerySm(value)
}
}
#[derive(Debug, Default)]
pub struct QuerySmBuilder<'a> {
inner: QuerySm<'a>,
}
impl<'a> QuerySmBuilder<'a> {
pub fn new() -> Self {
Default::default()
}
pub fn message_id(mut self, message_id: COctetString<'a, 1, 65>) -> Self {
self.inner.message_id = message_id;
self
}
pub fn source_addr_ton(mut self, source_addr_ton: Ton) -> Self {
self.inner.source_addr_ton = source_addr_ton;
self
}
pub fn source_addr_npi(mut self, source_addr_npi: Npi) -> Self {
self.inner.source_addr_npi = source_addr_npi;
self
}
pub fn source_addr(mut self, source_addr: COctetString<'a, 1, 21>) -> Self {
self.inner.source_addr = source_addr;
self
}
pub fn build(self) -> QuerySm<'a> {
self.inner
}
}
#[cfg(test)]
mod tests {
use crate::tests::TestInstance;
use super::*;
impl TestInstance for QuerySm<'_> {
fn instances() -> alloc::vec::Vec<Self> {
alloc::vec![
Self::default(),
Self::builder()
.message_id(COctetString::new(b"1234567890123456\0").unwrap())
.source_addr_ton(Ton::International)
.source_addr_npi(Npi::Isdn)
.source_addr(COctetString::new(b"Source Addr\0").unwrap())
.build(),
]
}
}
#[test]
fn encode_decode() {
crate::tests::borrowed::encode_decode_test_instances::<QuerySm>();
}
}