sms_pdu_decoder/
lib.rs

1pub mod codecs;
2pub mod easy;
3pub mod elements;
4pub mod fields;
5
6use thiserror::Error;
7
8// Re-export commonly used items
9pub use codecs::{GSM as Gsm7Bit, UCS2 as Ucs2};
10pub use easy::{read_incoming_sms, read_outgoing_sms, IncomingSms, OutgoingSms, PartialSmsInfo};
11pub use fields::{SMSDeliver as SmsDeliver, SMSSubmit as SmsSubmit};
12
13pub type Result<T> = std::result::Result<T, PDUError>;
14
15#[derive(Error, Debug, PartialEq)]
16pub enum PDUError {
17    #[error("Invalid PDU hex data: {0}")]
18    InvalidHex(#[from] hex::FromHexError),
19    #[error("PDU stream unexpectedly ended")]
20    EndOfPdu,
21    #[error("PDU data length is odd")]
22    OddLength,
23    #[error("Invalid character for GSM 7-bit encoding: '{0}'")]
24    InvalidGsmChar(char),
25    #[error("Invalid Type Of Address (TON/NPI): {0}")]
26    InvalidToa(String),
27    #[error("Invalid Message Type Indicator")]
28    InvalidMti,
29    #[error("Invalid Type Of Number bits")]
30    InvalidTon,
31    #[error("Invalid Numbering Plan Identification bits")]
32    InvalidNpi,
33    #[error("Invalid first bit of the Type Of Address octet")]
34    InvalidToaExtension,
35    #[error("Non-recognized encoding: {0}")]
36    NonRecognizedEncoding(String),
37    #[error("Truncated PDU: User data is shorter than specified by UDL.")]
38    UserDataTruncated,
39}