Expand description
§SMS Core
Core traits and types for the smskit multi-provider SMS abstraction.
This crate provides the fundamental building blocks for SMS operations:
SmsClienttrait for sending SMS messagesInboundWebhooktrait for processing incoming webhooksSmsRouterfor dispatching sends to named providersFallbackClientfor try-in-order provider chaining- Common types for requests, responses, and errors
§Sending a message
ⓘ
use sms_core::{SendRequest, SmsClient};
// Any SMS provider implements SmsClient
let response = client.send(SendRequest {
to: "+1234567890",
from: "+0987654321",
text: "Hello world!"
}).await?;§Owned requests for async contexts
When you need to hold a request across .await points, use OwnedSendRequest:
ⓘ
use sms_core::OwnedSendRequest;
let req = OwnedSendRequest::new("+1234567890", "+0987654321", "Hello!");
// Can be moved across .await boundaries freely
let response = client.send(req.as_ref()).await?;§Routing to named providers
ⓘ
use sms_core::SmsRouter;
let router = SmsRouter::new()
.with("plivo", plivo_client)
.with("aws-sns", sns_client);
// Dispatch by name — callers don't need provider crate imports
let response = router.send_via("plivo", SendRequest { .. }).await?;§Fallback chaining
ⓘ
use sms_core::FallbackClient;
let client = FallbackClient::new(vec![primary_client, backup_client]);
// Tries each provider in order; returns first success
let response = client.send(SendRequest { .. }).await?;Structs§
- Fallback
Client - An
SmsClientthat tries a list of providers in order, returning the first successful response. - Inbound
Message - A provider-normalized inbound SMS message (e.g. a reply or MO message).
- Inbound
Registry - A runtime registry that maps provider names to
InboundWebhookimplementations. - Owned
Send Request - An owned variant of
SendRequestfor use in async contexts. - Send
Request - A borrowing SMS send request.
- Send
Response - The response returned after a successful SMS send.
- SmsRouter
- Routes SMS sends to a named provider without requiring the caller to know about individual provider crate types.
- Webhook
Response - A framework-agnostic webhook HTTP response.
- Webhook
Result - Result of webhook processing, containing both the message and response info.
Enums§
- Http
Status - Minimal HTTP status codes used by
WebhookResponse. - SmsError
- Errors that can occur during SMS send operations.
- Webhook
Error - Errors specific to inbound webhook processing.
Traits§
- Inbound
Webhook - Provider-agnostic interface for processing inbound SMS webhooks.
- SmsClient
- The primary trait for sending SMS messages.
Functions§
- fallback_
id - Generate a random UUID v4 string, useful as a fallback message ID when the provider does not return one.
Type Aliases§
- Headers
- Lightweight header representation (
Vec<(name, value)>) that avoids coupling the core crate to any particular HTTP framework.