Skip to main content

BindRequest

Struct BindRequest 

Source
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: u32

Sequence number of the PDU

§mode: BindMode

Bind Mode (Receiver, Transmitter, Transceiver)

§system_id: String

System ID (Username)

§password: String

Password

§system_type: String

System Type (Verification of system type)

§interface_version: u8

Interface Version (e.g., 0x34 for SMPP 3.4)

§addr_ton: Ton

Address Type of Number (TON)

§addr_npi: Npi

Address Numbering Plan Indicator (NPI)

§address_range: String

Address Range (Regular Expression for routing)

Implementations§

Source§

impl BindRequest

Source

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(),
);
Source

pub fn with_address_range(self, ton: Ton, npi: Npi, range: String) -> Self

Builder pattern helper to set the address range fields.

Source

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_id exceeds 16 characters.
  • password exceeds 9 characters.
  • system_type exceeds 13 characters.
  • address_range exceeds 41 characters.
  • An I/O error occurs while writing.
§Examples
let mut buffer = Vec::new();
bind_req.encode(&mut buffer).expect("Encoding failed");
Source

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

Source§

fn clone(&self) -> BindRequest

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BindRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for BindRequest

Source§

fn eq(&self, other: &BindRequest) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for BindRequest

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V