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
//! 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 azure_iot_sdk::client::IoTHubClient;
//! use azure_iot_sdk::message::Message;
//! use tokio::time;
//!
//! #[tokio::main]
//! async fn main() {
//!     let mut client =
//!     IoTHubClient::from_connection_string("HostName=iothubname.azure-devices.net;DeviceId=MyDeviceId;SharedAccessKey=TheAccessKey").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;
//!     }
//! }
//! ```

#![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;
/// Message types for communicating with the IoT Hub
pub mod message;
pub(crate) mod mqtt_transport;