1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
//! # Rusmppc
//!
//! A [`tokio`](https://docs.rs/tokio/latest/tokio/) based [SMPP v5](https://smpp.org/SMPP_v5.pdf) client.
//!
//! ## Features
//!
//! - `rustls`: Enables TLS support via [`rustls`](https://docs.rs/rustls/latest/rustls/). Enabled by default.
//! - `rustls-tls-native-roots`: Uses the platform's native root certificates through [`rustls-native-certs`](https://docs.rs/rustls-native-certs/latest/rustls_native_certs/) while using default configuration. Enables the `rustls` feature and is enabled by default.
//! - `rustls-tls-webpki-roots`: Uses the [`webpki-roots`](https://docs.rs/webpki-roots/latest/webpki_roots/) crate's root certificates while using default configuration. Enables the `rustls` feature and is enabled by default.
//! - `rustls-aws-lc-rs`: Uses [`aws-lc-rs`](https://docs.rs/aws-lc-rs/latest/aws_lc_rs/) as the TLS backend for [`rustls`](https://docs.rs/rustls/latest/rustls/). Enabled by default.
//! - `rustls-ring`: Uses [`ring`](https://docs.rs/ring/latest/ring/) as the TLS backend for [`rustls`](https://docs.rs/rustls/latest/rustls/).
//! - `native-tls`: Enables TLS support via [`native-tls`](https://docs.rs/native-tls/latest/native_tls/).
//!
//! # Example
//!
//!```rust, no_run
//! use std::{str::FromStr, time::Duration};
//!
//! use futures::StreamExt;
//! use rusmpp::{
//! CommandId,
//! pdus::{BindTransceiver, DeliverSmResp, SubmitSm},
//! types::{COctetString, OctetString},
//! values::{EsmClass, Npi, RegisteredDelivery, ServiceType, Ton},
//! };
//! use rusmppc::{ConnectionBuilder, Event};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let (client, mut events) = ConnectionBuilder::new()
//! // Set the maximum command length for incoming commands.
//! .max_command_length(1024)
//! // Every 5 seconds send an enquire link command to the server.
//! .enquire_link_interval(Duration::from_secs(5))
//! // If the server did not respond within 3 seconds, close the connection.
//! .enquire_link_response_timeout(Duration::from_secs(3))
//! // If the server does not respond within 2 seconds, consider it a timeout.
//! // The operation is assumed to have failed.
//! .response_timeout(Duration::from_secs(2))
//! .connect("smpp://127.0.0.1:2775")
//! .await?;
//!
//! // Bind the client as a transceiver.
//! client
//! .bind_transceiver(
//! BindTransceiver::builder()
//! .system_id(COctetString::from_str("NfDfddEKVI0NCxO")?)
//! .password(COctetString::from_str("rEZYMq5j")?)
//! .system_type(COctetString::empty())
//! .addr_ton(Ton::Unknown)
//! .addr_npi(Npi::Unknown)
//! .address_range(COctetString::empty())
//! .build(),
//! )
//! .await?;
//!
//! let events = tokio::spawn(async move {
//! // Listen for events like incoming commands and background errors.
//! while let Some(event) = events.next().await {
//! println!("Event: {:?}", event);
//! }
//! });
//!
//! // Send commands to the server and wait for the responses.
//! let response = client
//! .submit_sm(
//! SubmitSm::builder()
//! .service_type(ServiceType::default())
//! .source_addr_ton(Ton::Unknown)
//! .source_addr_npi(Npi::Unknown)
//! .source_addr(COctetString::from_str("12345")?)
//! .destination_addr(COctetString::from_str("491701234567")?)
//! .esm_class(EsmClass::default())
//! .registered_delivery(RegisteredDelivery::request_all())
//! .short_message(OctetString::from_str("Hi, I am a short message.")?)
//! .build(),
//! )
//! .await?;
//!
//! println!("SubmitSm response: {:?}", response);
//!
//! // Send an unbind command to the server and wait for the response.
//! client.unbind().await?;
//!
//! // Close the connection.
//! client.close().await?;
//!
//! // Wait for the connection to be closed.
//! client.closed().await;
//!
//! // When the connection is closed, the event stream will also be closed.
//! events.await?;
//!
//! Ok(())
//! }
//! ```
pub use Action;
pub use ConnectionBuilder;
pub use Event;
pub use ;
pub use Timer;
pub use Client;
pub use CommandExt;
pub use RequestFutureGuard;
pub use PendingResponses;
pub use MaybeTlsStream;