aws-iot-device-sdk-rust 0.8.1

An easy to use SDK for connecting to AWS IoT Core.
Documentation
//! aws-iot-core-sdk-rust aims to be a well-functioning and easy to use AWS IoT device SDK.
//! At its core it uses the pure Rust MQTT client rumqttc. The name is chosen to match its C, C++, Python and JS counterparts.
//! * Use this to easily connect your IoT devices to AWS IoT Core.
//! * Publish and subscribe to any topic you want.
//! * Implement the AWSEventHandler trait for your struct.
//!
//! The crate re-exports Mqtt311s Quality of Service enum. These are used when subscribing and
//! publish. The variants are:
//! * AtMostOnce (0)
//! * AtLeastOnce (1)
//! * ExactlyOnce (2)
//!
//! ## Publish and subscribe
//! ```no_run
//!#[tokio::main]
//!async fn main() -> Result<(), Box<dyn std::error::Error>> {
//!    let aws_settings = aws_iot_device_sdk_rust::AWSIoTSettings::new(
//!        "clientid".to_owned(),
//!        "AmazonRootCA1.pem".to_owned(),
//!        "cert.crt".to_owned(),
//!        "key.pem".to_owned(),
//!        "endpoint.amazonaws.com".to_owned(),
//!        None
//!        );
//!
//!    let (iot_core_client, eventloop_stuff) = aws_iot_device_sdk_rust::AWSIoTAsyncClient::new(aws_settings).await?;
//!
//!    iot_core_client.subscribe("test".to_string(), rumqttc::QoS::AtMostOnce).await?;
//!    iot_core_client.publish("topic".to_string(), rumqttc::QoS::AtMostOnce, "hey").await?;
//!
//!    let mut receiver1 = iot_core_client.get_receiver().await;
//!    let mut receiver2 = iot_core_client.get_receiver().await;
//!
//!    let recv1_thread = tokio::spawn(async move {
//!        loop {
//!            match receiver1.recv().await {
//!                Ok(event) => {
//!                    match event {
//!                        rumqttc::Packet::Publish(p) => println!("Received message {:?} on topic: {}", p.payload, p.topic),
//!                        _ => println!("Got event on receiver1: {:?}", event),
//!                    }
//!
//!                },
//!                Err(_) => (),
//!            }
//!        }
//!    });
//!
//!    let recv2_thread = tokio::spawn(async move {
//!        loop {
//!            match receiver2.recv().await {
//!                Ok(event) => println!("Got event on receiver2: {:?}", event),
//!                Err(_) => (),
//!            }
//!        }
//!    });
//!
//!    let listen_thread = tokio::spawn(async move {
//!            aws_iot_device_sdk_rust::async_client::async_event_loop_listener(eventloop_stuff).await.unwrap();
//!    });
//!
//!    tokio::join!(
//!        recv1_thread,
//!        recv2_thread,
//!        listen_thread);
//!    Ok(())
//!}
//!
//!```

pub use rumqttc::{ClientError, ConnectionError, Event, EventLoop, Incoming, Packet, Publish, QoS, StateError, TlsConfiguration, Transport};
pub use self::{error::AWSIoTError, settings::AWSIoTSettings};
pub mod error;
pub mod settings;

#[cfg(feature = "async")]
pub mod async_client;
#[cfg(feature = "async")]
pub use self::async_client::{async_event_loop_listener, AWSIoTAsyncClient};
#[cfg(feature = "async")]
pub use rumqttc::AsyncClient;

#[cfg(feature = "sync")]
pub mod sync_client;
#[cfg(feature = "sync")]
pub use self::sync_client::{AWSIoTClient, EventBus};
#[cfg(feature = "sync")]
pub use bus::BusReader;
#[cfg(feature = "sync")]
pub use rumqttc::{Client, Connection};