astarte-device-sdk-0.9.0 has been yanked.
Astarte Device SDK Rust

Warning: this SDK is experimental, correctness and API stability are currently not guaranteed
The Astarte Device SDK for Rust is a ready to use library that provides communication and
pairing primitives to an Astarte Cluster.
See the Astarte documentation
for more information regarding Astarte and the available SDKs.
Basic usage
use std::error::Error as StdError;
use astarte_device_sdk::{
builder::DeviceBuilder,
transport::mqtt::MqttConfig,
error::Error,
prelude::*,
store::sqlite::SqliteStore,
};
async fn run_astarte_device() -> Result<(), Box<dyn StdError>> {
let realm = "realm_name";
let device_id = "device_id";
let credentials_secret = "device_credentials_secret";
let pairing_url = "astarte_cluster_pairing_url";
let db = SqliteStore::connect_db("/var/lib/astarte/store.db").await?;
let mut mqtt_config = MqttConfig::with_credential_secret(realm, device_id, credentials_secret, pairing_url);
mqtt_config.ignore_ssl_errors();
let (mut client, mut connection) = DeviceBuilder::new()
.interface_directory("./examples/interfaces")?
.store(db)
.connect(mqtt_config).await?
.build().await;
let data: i32 = 12;
client.send("interface.name", "/endpoint/path", data).await?;
use astarte_device_sdk::AstarteAggregate;
#[cfg(not(feature = "derive"))]
use astarte_device_sdk_derive::AstarteAggregate;
#[derive(Debug, AstarteAggregate)]
struct MyAggObj {
endpoint1: f64,
endpoint2: i32
}
let data = MyAggObj {endpoint1: 1.34, endpoint2: 22};
client.send_object("interface.name", "/common/endpoint/path", data).await?;
tokio::spawn(async move {
loop {
match client.recv().await {
Ok(data) => (), Err(err) => (), }
}
});
connection.handle_events().await?;
Ok(())
}
Building the library
You can build the library using:
cargo build
Examples
Check out how to start with the SDK using one of the included examples.