rusmpp_core/
fields.rs

1//! `SMPP` Fields.
2
3/// Every field defined in the `SMPP` protocol and extra fields defined in this library.
4///
5/// Used for verbose error handling while decoding invalid pdus, if the `verbose` feature is enabled.
6///
7/// # Example
8///
9/// ```rust
10/// # #[cfg(all(feature = "verbose", feature = "alloc"))]
11/// # {
12/// # use rusmpp_core::{command::owned::Command, decode::owned::DecodeWithLength, fields::SmppField};
13/// # use bytes::BytesMut;
14/// // bind_transmitter bytes
15/// // The `password` field is not null terminated.
16/// // The `decode` method will return an error with
17/// // the `SmppField::password` field as a source in
18/// // the sources tree.
19/// let mut bytes = BytesMut::from(&[
20///     // Header
21///     0x00, 0x00, 0x00, 0x2E, // Command Length (46 bytes total)
22///     0x00, 0x00, 0x00, 0x02, // Command ID (bind_transmitter)
23///     0x00, 0x00, 0x00, 0x00, // Command Status (0 - OK)
24///     0x00, 0x00, 0x00, 0x01, // Sequence Number (1)
25///
26///     // system_id: "SMPP3TEST\0"
27///     0x53, 0x4D, 0x50, 0x50, 0x33, 0x54, 0x45, 0x53, 0x54, 0x00,
28///     // password: "secret08" WRONG! not null terminated!
29///     0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x30, 0x38,
30///     // system_type: "SUBMIT1"
31///     0x53, 0x55, 0x42, 0x4D, 0x49, 0x54, 0x31, 0x00,
32///     // interface_version
33///     0x50,
34///     // addr_ton
35///     0x01,
36///     // addr_npi
37///     0x01,
38///     // addr_range
39///     0x00,
40/// ][..]);
41///
42/// let error = Command::decode(&mut bytes.split_off(4), 46 - 4).unwrap_err();
43///
44/// assert!(error.field_exists(SmppField::password));
45///
46/// // Knowing that the `password` field is invalid,
47/// // we can respond with `ESME_RINVPASWD` (Invalid Password).
48/// # }
49#[allow(non_camel_case_types)]
50#[derive(Debug, Copy, Clone, PartialEq, Eq)]
51#[non_exhaustive]
52pub enum SmppField {
53    addr,
54    addr_npi,
55    addr_ton,
56    address_range,
57    area,
58    data_coding,
59    dest_addr_npi,
60    dest_addr_ton,
61    dest_address,
62    destination_addr,
63    dl_name,
64    encoding_content_type,
65    error_code,
66    error_status_code,
67    esm_class,
68    esme_addr,
69    esme_addr_npi,
70    esme_addr_ton,
71    final_date,
72    format,
73    id,
74    interface_version,
75    message_id,
76    message_payload,
77    message_state,
78    ms_availability_status,
79    network_type,
80    no_unsuccess,
81    number_of_dests,
82    number_of_time_units,
83    password,
84    pdu,
85    priority_flag,
86    protocol_id,
87    registered_delivery,
88    replace_if_present_flag,
89    sc_interface_version,
90    schedule_delivery_time,
91    sequence_number,
92    service_type,
93    session_number,
94    short_message,
95    sm_default_msg_id,
96    sm_length,
97    source_addr,
98    source_addr_npi,
99    source_addr_ton,
100    status,
101    system_id,
102    system_type,
103    tag,
104    tlvs,
105    type_of_network,
106    unit,
107    units_of_time,
108    unsuccess_sme,
109    user_message_reference,
110    validity_behavior,
111    validity_information,
112    validity_period,
113    value,
114    value_length,
115    udh_length,
116    udh_id,
117    udh_value,
118}