Vonage (formerly Nexmo) API bindings for Rust.
This library (vonage-rs
) is intended to be an idiomatic Rust equivalent of
vonage-node-sdk
. It enables you to quickly add communications functionality
to your application, including sending SMS messages, making voice calls,
text-to-speech, gathering phone number insights, two-factor authentication, and
more.
To use this library, a Vonage account is required. If you don't have an account, you can always sign up for free.
See developer.nexmo.com for upstream documentation.
use std::error::Error;
use std::io::BufRead;
use std::time::Duration;
use vonage::verify::{Code, CodeLength};
use vonage::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let client = Client::new("<api_key>", "<api_secret>");
let mut pending = client
.verify("+1 555-555-555".parse()?, "vonage-rs")?
.code_length(CodeLength::Six)
.pin_expiry(Duration::from_secs(5 * 60))
.send()
.await?;
let stdin = std::io::stdin();
let mut lines = stdin.lock().lines();
let matched = loop {
let code = lines.next().unwrap()?;
match pending.check(&code).await? {
Code::Match(matched) => break matched,
Code::Mismatch(p) => pending = p,
}
};
println!("Code matches! {:?}", matched);
Ok(())
}
Below are the non-beta products that vonage-rs
aims to support, at minimum:
- SMS API (sending SMS messages)
- Verify (2FA) API (user authentication)
- Voice API (making voice calls)
Below are the non-beta nice-to-have products that vonage-rs
may support later:
- Account API (managing your own Vonage account balance)
- Application API (managing your Vonage-connected applications)
- Number Insight API (retrieving phone number validity info)
- Video API (embeddable video and screen sharing capabilities)
vonage-rs
is free and open source software distributed under the terms of
either the MIT or the Apache 2.0 license, at
your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.