Hi, I'm trying to send a phone text message through Rust to validate peoples' phone numbers to register their accounts on a web app I'm building. I've copied and pasted the code seen on the crate's site and properly added in the additional dependencies but it still shows an error at "let fut = fut.and_then" saying that there's no method named "and_then" found for the struct. Could someone provide a fix for this and also if possible give a short explanation on how to use this to send sms messages? I'm assuming you swap out SMS_RECIPIENT with the actual phone number, but that's about it. Do you need an access code or does the copied code already include it?
This is the code from the messagebird-async crate:
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate futures;
extern crate messagebird_async;
extern crate tokio_core;
use futures::future::Future;
use messagebird_async::errors::*;
use messagebird_async::sms;
use messagebird_async::sms::*;
fn main() -> Result<(), MessageBirdError> {
env_logger::init();
let msisdn_str = std::env::var("SMS_RECIPIENT".to_string())
.expect("SMS_RECIPIENT should contain the number without prefix");
let msisdn: Msisdn = Msisdn::from_str(msisdn_str.as_str())
.expect("SMS_RECIPIENT did not contain a valid number");
info!("example: sending a message");
let sendable = sms::send::SendParameters::builder()
.payload(
PayloadType::Sms,
Payload::Text("fun".to_string()),
PayloadEncoding::Auto,
)
.origin(AlphaNumeric("inbox".to_string()).into())
.add_recipient(msisdn.into())
//.add_recipient(Recipient::new())
.build();
let accesskey = AccessKey::from_env()?;
let fut = RequestSend::new(&sendable, &accesskey);
let fut = fut.and_then(|sent_msg: Message| {
info!("{:?}", sent_msg);
futures::future::ok(())
});
let mut core = tokio_core::reactor::Core::new().unwrap();
core.run(fut.map(|_| ()))
}