smpp_pdu/pdu/operations/
bind_transceiver.rs1use std::io;
2
3use crate::pdu::data::bind_data::BindData;
4use crate::pdu::formats::WriteStream;
5use crate::pdu::PduParseError;
6
7#[derive(Debug, PartialEq)]
8pub struct BindTransceiverPdu(pub BindData);
9
10impl BindTransceiverPdu {
11 pub fn new(
12 system_id: &str,
13 password: &str,
14 system_type: &str,
15 interface_version: u8,
16 addr_ton: u8,
17 addr_npi: u8,
18 address_range: &str,
19 ) -> Result<Self, PduParseError> {
20 Ok(Self(BindData::new(
21 system_id,
22 password,
23 system_type,
24 interface_version,
25 addr_ton,
26 addr_npi,
27 address_range,
28 )?))
29 }
30
31 pub async fn write(&self, stream: &mut WriteStream) -> io::Result<()> {
32 self.0.write(stream).await
33 }
34
35 pub fn parse(
36 bytes: &mut dyn io::BufRead,
37 command_status: u32,
38 ) -> Result<Self, PduParseError> {
39 Ok(Self(BindData::parse(bytes, command_status)?))
40 }
41
42 pub fn validate_command_status(
43 self,
44 command_status: u32,
45 ) -> Result<Self, PduParseError> {
46 Ok(Self(self.0.validate_command_status(command_status)?))
47 }
48
49 pub fn bind_data(&self) -> &BindData {
50 &self.0
51 }
52}