📞 SignalWire SDK for Rust 🦀
The unofficial SDK for interacting with SignalWire's API using Rust. This library provides methods for authentication, phone number management, and messaging capabilities.
🚀 Features
- 🔐 Authenticate: Obtain JWT tokens for secure API access.
- 📞 Phone Number Management: Retrieve available and owned phone numbers.
- 📱 SMS Messaging: Send SMS messages and check delivery status.
- ⚡ Asynchronous Support: Built with async/await using Tokio.
- 🕛 Blocking Support: Support for synchronous operations.
📦 Installation
Add the following to your Cargo.toml:
[]
= "0.1.6"
= "0.15.0"
= { = "1.42.0", = ["full"] }
or install with cargo, in the root of your project:
or you can request the blocking version:
[]
= { = "0.1.6", = ["blocking"] }
⚙️ Configuration
You can use environment variables to manage sensitive data. Create a .env file in your project root:
SIGNALWIRE_SPACE_NAME=your_space_name
SIGNALWIRE_PROJECT_ID=your_project_id
SIGNALWIRE_API_KEY=your_api_key
📚 Usage (Async)
Initialize the Client
use ;
use dotenv;
use env;
async
Get Available Phone Numbers
let client = new;
let query_params = new.build;
let available_numbers = client.get_phone_numbers_available.await?;
println!;
Get Owned Phone Numbers
let client = new;
let query_params = new.build;
let owned_numbers = client.get_phone_numbers_owned.await?;
println!;
Send SMS Message
use SmsMessage;
let client = new;
// Create message
let message = SmsMessage ;
// Send the message
match client.send_sms.await
Check Message Status
// Check the status of a previously sent message
let message_sid = "previous-message-sid";
match client.get_message_status.await
📚 Usage (Blocking)
With the blocking feature enabled, you can use synchronous versions of all methods:
use ;
use dotenv;
use env;
🛡️ Error Handling
The SDK provides a custom error type, SignalWireError, to handle various error scenarios, such as:
HttpError: Issues with HTTP requests.Unauthorized: Authentication failures.NotFound: Resource not found (e.g., invalid message SID).Unexpected: Other unexpected errors.
📜 License
This project is licensed under the BSD-3-Clause License
🤝 Contributing
Contributions are welcome! Please open an issue or submit a pull request.
📧 Contact
For questions or feedback, reach out to chiarel@tragdate.ninja
📝 Changelog
0.1.6
- Added SMS messaging functionality
- Added message status checking capability
- Added message status enum for better type safety
- Added NotFound error variant
0.1.5
- Initial release with JWT authentication
- Added phone number management
- Added blocking support