SMS Client
A remote client library for interfacing with the sms-server, making it easy to send and receive SMS messages from Rust, all with your own hardware and no API subscriptions!
This also includes bindings to the SMS database, useful for retrieving previous messages and delivery states.
Installation
Simply use cargo add sms-client
Here's some other usage examples from inside a project Cargo.toml.
[]
# Includes ONLY the HttpClient.
= "3.1.0"
# Includes BOTH the HttpClient and WebSocketClient.
= { = "3.1.0", = ["websocket"] }
# Includes ONLY the WebSocketClient.
= { = "3.1.0", = false, = ["websocket"] }
# Includes BOTH, with Rust-TLS.
= { = "3.1.0", = ["http-tls-rustls", "websocket-tls-rustls"] }
# Includes BOTH, with native TLS.
= { = "3.1.0", = ["http-tls-native", "websocket-tls-native"] }
Compilation Features
When enabling a TLS feature (eg:
websocket-tls-native) the base feature (websocket) is also enabled.
| Feature Name | Description | Default |
|---|---|---|
| http | Enables HttpClient to send commands to API. | Yes |
| websocket | Enables WebSocketClient to receive events from API. | No |
| http-tls-rustls | Uses Rust-TLS for reqwest HTTP client. | Yes |
| http-tls-native | Uses default TLS for reqwest HTTP client. | No |
| websocket-tls-rustls | Uses Rust-TLS for WebSocket client. | No |
| websocket-tls-native | Uses default TLS for WebSocket client. | No |
Example Projects
Here are two example projects that use this crate:
- Pushover - Send Pushover notifications for Incoming messages
- sms-terminal (crates.io) - Send and receive SMS messages via a TUI application
Examples
HTTP Response Pagination
Read every message stored for a phone number in chunks of 50 (default). This is useful for lazy loading messages when the total message count is very high.
async
Echo Replies
Listen for incoming SMS messages, and then reply with the same message content.
use Client;
use ;
use ClientResult;
use WebsocketEvent;
use Event;
use ;
async