Unimatrix Rust SDK
The Unimatrix Rust SDK provides convenient access to integrate communication capabilities into your Rust applications using the Unimatrix HTTP API. The SDK provides support for sending SMS and 2FA verification.
Getting started
Before you begin, you need an Unimatrix account. If you don't have one yet, you can sign up for an Unimatrix account and get free credits to get you started.
Documentation
Check out the documentation at unimtx.com/docs for a quick overview.
Installation
The SDK uses an asynchronous client by default. Add uni-sdk and an async runtime to your Cargo.toml:
[]
= "0.3"
= { = "1", = ["macros", "rt-multi-thread"] }
To use the synchronous client, enable the blocking feature. An async runtime is not required by the application:
[]
= { = "0.3", = ["blocking"] }
The SDK requires Rust 1.86 or later.
Usage
The following examples show how to use the Unimatrix Rust SDK to interact with Unimatrix services.
Initialize a client
use UniClient;
Or configure your credentials using environment variables:
use UniClient;
Send SMS
Send a text message to a single recipient.
use ;
async
Send verification code
Send a one-time passcode (OTP) to a recipient. The following example sends an automatically generated verification code.
use ;
async
Check verification code
Verify the one-time passcode that a user provided.
use ;
async
Handle errors
API errors include the error code, HTTP status, and request ID.
use ;
async
Synchronous (non-async) client
Use uni_sdk::blocking::UniClient when your application does not use an async runtime. Its API mirrors the async client but does not require .await. Avoid calling the blocking client directly from an async task, because it blocks that task's executor thread.
use ;
Reference
Other Unimatrix SDKs
To find Unimatrix SDKs in other programming languages, check out the list below:
License
This library is released under the MIT License.