Skip to main content

DeliverReport

Struct DeliverReport 

Source
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

最终状态,例如 DELIVRDEXPIREDUNDELIV

§submit_time: String

Submit time,yyMMddHHmm

§done_time: String

Done time,yyMMddHHmm

§dest_terminal_id: String

Destination terminal id(mobile number)。

§smsc_sequence: u32

SMSC sequence number。

Implementations§

Source§

impl DeliverReport

Source

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}
Source

pub fn parse(content: &[u8]) -> Option<DeliverReport>

解析 60-byte status report payload。长度不足时返回 None

Trait Implementations§

Source§

impl Clone for DeliverReport

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for DeliverReport

Source§

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

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

impl Eq for DeliverReport

Source§

impl PartialEq for DeliverReport

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 DeliverReport

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> Same for T

Source§

type Output = T

Should always be Self
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.