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.
= "1.7.1"
# Includes BOTH the HttpClient and WebSocketClient.
= { = "1.7.1", = ["websocket"] }
# Includes ONLY the WebSocketClient.
= { = "1.7.1", = false, = ["websocket"] }
# Includes BOTH, with Rust-TLS.
= { = "1.7.1", = ["http-tls-rustls", "websocket-tls-rustls"] }
# Includes BOTH, with native TLS.
= { = "1.7.1", = ["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
Example Code
This is an example that listens for incoming SMS messages, and then replies with the same message content.
use Arc;
use SmsStoredMessage;
use WebsocketMessage;
use HttpOutgoingSmsMessage;
use ClientConfig;
use ClientResult;
use Client;
async