1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
//! Azure IoT device client for writing iot device code in rust //! //! ## Feature flags //! //! SDK client uses [feature //! flags](https://doc.rust-lang.org/cargo/reference/features.html#the-features-section) to //! configure capabilities of the client sdk. By default all features are enabled. //! //! Device to cloud messaging is always available. //! //! - `c2d-messages`: Enables cloud to device messaging //! - `twin-properties`: Enables device twin property updates //! - `direct-methods`: Enables listening for direct method invocations //! //! ### Disabling capabilities //! If not all features are required, disable the default features and add only desired. //! //! ```toml //! azure_iot_sdk = { version = "0.3.0", features = [], default-features = false } //! ``` //! //! # Examples //! //! A simple client //! ```no_run //! use tokio::time; //! use azure_iot_sdk::{IoTHubClient, DeviceKeyTokenSource, Message}; //! //! #[tokio::main] //! async fn main() -> azure_iot_sdk::Result<()> { //! let iothub_hostname = "iothubname.azure-devices.net"; //! let device_id = "MyDeviceId"; //! let token_source = DeviceKeyTokenSource::new( //! iothub_hostname, //! device_id, //! "TheAccessKey", //! ).unwrap(); //! //! let mut client = //! IoTHubClient::new(iothub_hostname, device_id.into(), token_source).await?; //! //! let mut interval = time::interval(time::Duration::from_secs(1)); //! let mut count: u32 = 0; //! //! loop { //! interval.tick().await; //! //! let msg = Message::builder() //! .set_body(format!("Message #{}", count).as_bytes().to_vec()) //! .set_message_id(format!("{}-t", count)) //! .build(); //! //! client.send_message(msg).await?; //! //! count += 1; //! } //! //! Ok(()) //! } //! ``` #![warn(missing_debug_implementations, rust_2018_idioms, missing_docs)] #[macro_use] extern crate log; /// IoT SDK package version pub const SDK_VERSION: &str = std::env!("CARGO_PKG_VERSION"); /// The IoT Hub client pub mod client; pub use client::*; // #[cfg(feature = "http-transport")] // pub(crate) mod http_transport; /// Message types for communicating with the IoT Hub pub mod message; pub use message::*; /// #[cfg(feature = "https-transport")] pub(crate) mod http_transport; /// #[cfg(not(feature = "https-transport"))] pub(crate) mod mqtt_transport; /// pub mod token; pub use token::*; /// Transport types pub mod transport; #[cfg(feature = "with-provision")] /// Provision support using Azure device provisioning service pub mod provision; /// Convenience type alias for `std::result::Result<T, Box<dyn std::error::Error>>` pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;