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
Create a device
Initializing an instance of a device can be performed in three steps, as seen below.
use ;
// (optional) Initialize a database to store the properties
let db = new.await.unwrap;
// Initialize device options
let sdk_options = new
.interface_directory
.unwrap
.database;
// Create the device instance
let mut device = new.await.unwrap;
Publish data from device
Publishing new values can be performed using the send and send_object functions.
// Send individual datastream or set individual property
let data: i32 = 12;
device.send.await.unwrap;
// Send aggregated object datastream
let data = MyAggObj ;
device.send_object.await.unwrap;
Receive a server publish
Polling for new data can be performed using the function handle_events.
loop
Building the library
You can build the library using:
Examples
You can execute one of the examples using the following command (seen for the simple example).