use smpp_codec::common::{Npi, Ton};
use smpp_codec::pdus::{Destination, SubmitMulti};
fn main() {
println!("=== SMPP Submit Multi Example ===");
let dest_sme = Destination::SmeAddress {
ton: Ton::International,
npi: Npi::Isdn,
address: "1234567890".to_string(),
};
let dest_dl = Destination::DistributionList("MyGroup".to_string());
let destinations = vec![dest_sme, dest_dl];
println!("Targeting {} destinations.", destinations.len());
let mut req = SubmitMulti::new(
1001,
"Sender".to_string(),
destinations,
b"Hello Multicast World!".to_vec(),
);
req.priority_flag = 1;
req.registered_delivery = 1;
let mut buffer = Vec::new();
match req.encode(&mut buffer) {
Ok(_) => println!(
"Successfully encoded SubmitMulti PDU: {} bytes",
buffer.len()
),
Err(e) => eprintln!("Failed to encode PDU: {:?}", e),
}
match SubmitMulti::decode(&buffer) {
Ok(decoded) => {
println!("Successfully decoded PDU.");
println!(" Sequence: {}", decoded.sequence_number);
println!(" Destinations: {}", decoded.destinations.len());
println!(
" Message: {:?}",
String::from_utf8_lossy(&decoded.short_message)
);
}
Err(e) => eprintln!("Failed to decode PDU: {:?}", e),
}
}