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§mode: BindMode§system_id: String§password: String§system_type: String§interface_version: u8§addr_ton: Ton§addr_npi: Npi§address_range: String

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(),
);
Examples found in repository?
examples/bind_transceiver.rs (lines 8-13)
4fn main() {
5    println!("=== SMPP Bind Transceiver Example ===");
6
7    // 1. Create a BindTransceiver Request
8    let bind_req = BindRequest::new(
9        1, // Sequence Number
10        BindMode::Transceiver,
11        "my_system_id".to_string(),
12        "password".to_string(),
13    )
14    .with_address_range(Ton::International, Npi::Isdn, "12345".to_string());
15
16    println!("Created PDU: {:?}", bind_req);
17
18    // 2. Encode into bytes
19    let mut buffer = Vec::new();
20    match bind_req.encode(&mut buffer) {
21        Ok(_) => {
22            println!("Encoded successfully! {} bytes", buffer.len());
23            print!("Hex encoded: ");
24            for byte in &buffer {
25                print!("{:02X} ", byte);
26            }
27            println!();
28        }
29        Err(e) => {
30            eprintln!("Failed to encode: {:?}", e);
31        }
32    }
33}
Source

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

Examples found in repository?
examples/bind_transceiver.rs (line 14)
4fn main() {
5    println!("=== SMPP Bind Transceiver Example ===");
6
7    // 1. Create a BindTransceiver Request
8    let bind_req = BindRequest::new(
9        1, // Sequence Number
10        BindMode::Transceiver,
11        "my_system_id".to_string(),
12        "password".to_string(),
13    )
14    .with_address_range(Ton::International, Npi::Isdn, "12345".to_string());
15
16    println!("Created PDU: {:?}", bind_req);
17
18    // 2. Encode into bytes
19    let mut buffer = Vec::new();
20    match bind_req.encode(&mut buffer) {
21        Ok(_) => {
22            println!("Encoded successfully! {} bytes", buffer.len());
23            print!("Hex encoded: ");
24            for byte in &buffer {
25                print!("{:02X} ", byte);
26            }
27            println!();
28        }
29        Err(e) => {
30            eprintln!("Failed to encode: {:?}", e);
31        }
32    }
33}
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");
Examples found in repository?
examples/bind_transceiver.rs (line 20)
4fn main() {
5    println!("=== SMPP Bind Transceiver Example ===");
6
7    // 1. Create a BindTransceiver Request
8    let bind_req = BindRequest::new(
9        1, // Sequence Number
10        BindMode::Transceiver,
11        "my_system_id".to_string(),
12        "password".to_string(),
13    )
14    .with_address_range(Ton::International, Npi::Isdn, "12345".to_string());
15
16    println!("Created PDU: {:?}", bind_req);
17
18    // 2. Encode into bytes
19    let mut buffer = Vec::new();
20    match bind_req.encode(&mut buffer) {
21        Ok(_) => {
22            println!("Encoded successfully! {} bytes", buffer.len());
23            print!("Hex encoded: ");
24            for byte in &buffer {
25                print!("{:02X} ", byte);
26            }
27            println!();
28        }
29        Err(e) => {
30            eprintln!("Failed to encode: {:?}", e);
31        }
32    }
33}
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

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