pub struct DeliverReport {
pub msg_id: [u8; 8],
pub stat: String,
pub submit_time: String,
pub done_time: String,
pub dest_terminal_id: String,
pub smsc_sequence: u32,
}Expand description
已解析的 CMPP 2.0 status report(registered_delivery == 1 的 DELIVER content)。
Fields§
§msg_id: [u8; 8]当前 report 指向的原始 SUBMIT 的 Msg_Id(8 bytes)。
stat: String最终状态,例如 DELIVRD、EXPIRED、UNDELIV。
submit_time: StringSubmit time,yyMMddHHmm。
done_time: StringDone time,yyMMddHHmm。
dest_terminal_id: StringDestination terminal id(mobile number)。
smsc_sequence: u32SMSC sequence number。
Implementations§
Source§impl DeliverReport
impl DeliverReport
Sourcepub fn msg_id_hex(&self) -> String
pub fn msg_id_hex(&self) -> String
DeliverReport::msg_id 的小写 hex 表示。
Examples found in repository?
examples/send_sms.rs (line 58)
10async fn main() -> cmppprotocol::Result<()> {
11 let args: Vec<String> = std::env::args().collect();
12 if args.len() < 7 {
13 eprintln!("用法: send_sms <host> <port> <account> <password> <dest> <text>");
14 std::process::exit(2);
15 }
16 let (host, port, account, password, dest, text) = (
17 args[1].clone(),
18 args[2].parse::<i32>().expect("端口"),
19 args[3].clone(),
20 args[4].clone(),
21 args[5].clone(),
22 args[6].clone(),
23 );
24
25 let config = CmppConfig {
26 host,
27 port,
28 account: account.clone(),
29 password,
30 version: cmppprotocol::CMPP_VERSION_20,
31 protocol_params: CmppProtocolParams::default(),
32 };
33
34 let conn = CmppConnection::connect(config).await?;
35 println!("已连接并登录");
36
37 if let Some(mut events) = conn.take_events().await {
38 tokio::spawn(async move {
39 while let Some(event) = events.recv().await {
40 match event {
41 Event::SubmitResp {
42 sequence_id,
43 msg_id,
44 result,
45 } => {
46 println!(
47 "响应 seq={} msg_id={} result={}",
48 sequence_id,
49 Event::msg_id_hex(&msg_id),
50 result
51 );
52 }
53 Event::SubmitTimeout { sequence_id } => {
54 println!("submit 超时 seq={}", sequence_id)
55 }
56 Event::Deliver(deliver) => match deliver.report() {
57 Some(report) => {
58 println!("status report {} -> {}", report.msg_id_hex(), report.stat)
59 }
60 None => println!("来自 {} 的 MO message", deliver.src_terminal_id),
61 },
62 Event::Disconnected(e) => {
63 println!("connection 已断开: {}", e);
64 break;
65 }
66 }
67 }
68 });
69 }
70
71 let opts = SubmitOptions::new("SVC", &account, "10690001", &dest);
72 let seq_ids = conn.submit(&opts, &text, None).await?;
73 println!("已提交 {} 个 segment: {:?}", seq_ids.len(), seq_ids);
74
75 // 关闭前给 ISMG 一点时间推送 response / status report。
76 tokio::time::sleep(Duration::from_secs(5)).await;
77 conn.close().await;
78 Ok(())
79}Sourcepub fn parse(content: &[u8]) -> Option<DeliverReport>
pub fn parse(content: &[u8]) -> Option<DeliverReport>
解析 60-byte status report payload。长度不足时返回 None。
Trait Implementations§
Source§impl Clone for DeliverReport
impl Clone for DeliverReport
Source§fn clone(&self) -> DeliverReport
fn clone(&self) -> DeliverReport
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 DeliverReport
impl Debug for DeliverReport
impl Eq for DeliverReport
Source§impl PartialEq for DeliverReport
impl PartialEq for DeliverReport
Source§fn eq(&self, other: &DeliverReport) -> bool
fn eq(&self, other: &DeliverReport) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for DeliverReport
Auto Trait Implementations§
impl Freeze for DeliverReport
impl RefUnwindSafe for DeliverReport
impl Send for DeliverReport
impl Sync for DeliverReport
impl Unpin for DeliverReport
impl UnsafeUnpin for DeliverReport
impl UnwindSafe for DeliverReport
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