smskit -- Universal Multi-Provider SMS Toolkit for Rust
Status: v0.2.0 (beta) -- Complete framework-agnostic SMS abstraction with support for every major Rust web framework.
Why smskit?
Give your users the freedom to bring their own SMS provider while you code to a single, unified interface. Switch between Plivo, Twilio, AWS SNS seamlessly without changing your application code.
NEW in v0.2.0: Universal web framework support, unified dispatch router, fallback chaining, from_env() constructors, and owned request types for async ergonomics.
Architecture
sms-core
(traits & types)
SmsClient trait
SmsRouter
FallbackClient
|
+--------------+--------------+
| | |
sms-plivo sms-twilio sms-aws-sns
| | |
+--------------+--------------+
|
sms-web-generic
(framework-agnostic
webhook processing)
|
+-------+-------+--+--+-------+-------+
| | | | | |
Axum Warp Actix-web Rocket Poem Hyper Tide
Quick Start
Sending SMS
use ;
use PlivoClient;
// Create from explicit credentials...
let client = new;
// ...or from environment variables
let client = from_env?;
let response = client.send.await?;
println!;
Unified Dispatch (no provider imports needed)
use ;
let router = new
.with
.with
.with
.default_provider;
// Dispatch by name:
router.send_via.await?;
// Or use the default:
router.send.await?;
Fallback Chaining
use FallbackClient;
use Arc;
let client = new;
// Tries primary first; on failure, tries backup.
let response = client.send.await?;
Owned Requests for Async Contexts
use OwnedSendRequest;
// Owns its data -- can be held across .await points
let req = new;
let response = client.send.await?;
Environment-Based Construction
Every provider supports from_env():
use PlivoClient; // reads PLIVO_AUTH_ID, PLIVO_AUTH_TOKEN
use TwilioClient; // reads TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN
use AwsSnsClient; // reads AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
let plivo = from_env?;
let twilio = from_env?;
let aws = from_env?;
Receiving SMS (Webhooks)
All frameworks receive the same normalized InboundMessage:
Webhook URLs:
- POST
http://yourserver.com/webhooks/plivo - POST
http://yourserver.com/webhooks/twilio - POST
http://yourserver.com/webhooks/aws-sns
SMS Providers
| Provider | Crate | Send | Webhooks | Signature Verification | from_env() |
|---|---|---|---|---|---|
| Plivo | sms-plivo |
Yes | Yes | -- | Yes |
| Twilio | sms-twilio |
Yes | Yes | HMAC-SHA1 | Yes |
| AWS SNS | sms-aws-sns |
Yes | Yes | -- | Yes |
Supported Frameworks
| Framework | Crate | Example |
|---|---|---|
| Axum | sms-web-axum |
Example |
| Warp | sms-web-warp |
Example |
| Actix-web | sms-web-actix |
Example |
| Rocket | sms-web-rocket |
Example |
| Tide | sms-web-tide |
Example |
| Hyper | sms-web-hyper |
Example |
| Generic | sms-web-generic |
DIY Integration |
| Your Framework | DIY | Use sms-web-generic! |
Running Examples
# Generic integration (works everywhere)
# Framework-specific
Configuration
Copy config/default.toml and adjust for your environment. Configuration loads from:
- Built-in defaults
config/default.tomlconfig/{environment}.toml(setRUN_MODE=production)config/local.toml(gitignored)SMSKIT_prefixed environment variables
License
MIT OR Apache-2.0