pub struct BindRequest {
pub sequence_number: u32,
pub mode: BindMode,
pub system_id: String,
pub password: String,
pub system_type: String,
pub interface_version: u8,
pub addr_ton: Ton,
pub addr_npi: Npi,
pub address_range: String,
}Expand description
Represents a Bind Request PDU (Receiver, Transmitter, or Transceiver).
This PDU is used to initiate a session with the SMSC.
Fields§
§sequence_number: u32Sequence number of the PDU
mode: BindModeBind Mode (Receiver, Transmitter, Transceiver)
system_id: StringSystem ID (Username)
password: StringPassword
system_type: StringSystem Type (Verification of system type)
interface_version: u8Interface Version (e.g., 0x34 for SMPP 3.4)
addr_ton: TonAddress Type of Number (TON)
addr_npi: NpiAddress Numbering Plan Indicator (NPI)
address_range: StringAddress Range (Regular Expression for routing)
Implementations§
Source§impl BindRequest
impl BindRequest
Sourcepub fn new(
sequence_number: u32,
mode: BindMode,
system_id: String,
password: String,
) -> Self
pub fn new( sequence_number: u32, mode: BindMode, system_id: String, password: String, ) -> Self
Create a new Bind Request with defaults.
§Examples
use smpp_codec::pdus::BindRequest;
use smpp_codec::common::BindMode;
let sequence_number: u32 = 1;
let bind_req = BindRequest::new(
sequence_number,
BindMode::Transceiver,
"system_id".to_string(),
"password".to_string(),
);Sourcepub fn with_address_range(self, ton: Ton, npi: Npi, range: String) -> Self
pub fn with_address_range(self, ton: Ton, npi: Npi, range: String) -> Self
Builder pattern helper to set the address range fields.
Sourcepub fn encode(&self, writer: &mut impl Write) -> Result<(), PduError>
pub fn encode(&self, writer: &mut impl Write) -> Result<(), PduError>
Encode the struct into raw bytes for the network.
§Errors
Returns a PduError if:
system_idexceeds 16 characters.passwordexceeds 9 characters.system_typeexceeds 13 characters.address_rangeexceeds 41 characters.- An I/O error occurs while writing.
§Examples
let mut buffer = Vec::new();
bind_req.encode(&mut buffer).expect("Encoding failed");Sourcepub fn decode(buffer: &[u8]) -> Result<Self, PduError>
pub fn decode(buffer: &[u8]) -> Result<Self, PduError>
Decode raw bytes from the network into the struct.
§Errors
Returns a PduError if:
- The buffer is too short to contain a valid header.
- The command ID does not correspond to a Bind Request.
- The buffer data is malformed.
§Examples
let decoded = BindRequest::decode(&buffer).expect("Decoding failed");
assert_eq!(decoded.system_id, "id");Trait Implementations§
Source§impl Clone for BindRequest
impl Clone for BindRequest
Source§fn clone(&self) -> BindRequest
fn clone(&self) -> BindRequest
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BindRequest
impl Debug for BindRequest
Source§impl PartialEq for BindRequest
impl PartialEq for BindRequest
impl StructuralPartialEq for BindRequest
Auto Trait Implementations§
impl Freeze for BindRequest
impl RefUnwindSafe for BindRequest
impl Send for BindRequest
impl Sync for BindRequest
impl Unpin for BindRequest
impl UnwindSafe for BindRequest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more