| Crates.io | smsru |
| lib.rs | smsru |
| version | 0.1.0 |
| created_at | 2026-01-20 06:34:00.847736+00 |
| updated_at | 2026-01-20 06:34:00.847736+00 |
| description | Typed Rust client for the SMS.RU HTTP API. |
| homepage | https://github.com/matrizaev/smsru |
| repository | https://github.com/matrizaev/smsru |
| max_upload_size | |
| id | 2055901 |
| size | 120,519 |
Typed Rust client for the SMS.RU HTTP API (sms/send).
This crate focuses on a small, explicit public API: strong domain types for inputs and a client that handles JSON responses. Transport details are internal and not exposed as public modules.
The client is async and expects a Tokio runtime.
Minimum supported Rust version: 1.85 (edition 2024).
use smsru::{Auth, MessageText, RawPhoneNumber, SendOptions, SendSms, SmsRuClient};
# async fn run() -> Result<(), smsru::SmsRuError> {
let client = SmsRuClient::new(Auth::api_id("...")?);
let recipients = vec![
RawPhoneNumber::new("+79255070602")?,
RawPhoneNumber::new("+74993221627")?,
];
let msg = MessageText::new("hello world")?;
let request = SendSms::to_many(recipients, msg, SendOptions::default())?;
let response = client.send_sms(request).await?;
println!("status: {:?} code: {:?}", response.status, response.status_code);
# Ok(())
# }
Auth::api_id("...")?Auth::login_password("login", "password")?SendSms::to_many(Vec<RawPhoneNumber>, MessageText, SendOptions)SendSms::per_recipient(BTreeMap<RawPhoneNumber, MessageText>, SendOptions)use std::collections::BTreeMap;
use smsru::{MessageText, RawPhoneNumber, SendOptions, SendSms};
fn build() -> Result<SendSms, smsru::ValidationError> {
let mut messages = BTreeMap::new();
messages.insert(
RawPhoneNumber::new("+79251234567")?,
MessageText::new("hello")?,
);
Ok(SendSms::per_recipient(messages, SendOptions::default())?)
}
RawPhoneNumber preserves input as-is after trimming whitespace.PhoneNumber::parse(default_region, input) validates and normalizes to E.164. Convert to RawPhoneNumber when building requests.Use SmsRuClient::builder(auth) to configure endpoint, timeout, and user_agent.
Responses preserve SMS.RU status codes via StatusCode. Known codes are mapped to KnownStatusCode through StatusCode::known_kind().
The client always sends json=1 and only supports JSON responses. JsonMode::Plain is rejected by the client.