Rust

This guide provides a walk-through of how to install the latest version of Rust and Cargo along with the MQTT Client library.‌

Installing Rust

‌Install Rust and the package manager Cargo by running the following command:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Add Cargo's bin directory ($HOME/.cargo/bin) in your PATH environment variable. Next time you log in this will be done automatically.

. $HOME/.cargo/env

Check the installation and Rust version:

rustc --version
rustc 1.49.0 (e1884a8e3 2020-12-29)

Install the dependency:

sudo apt-get install libssl-dev

Installing MQTT Client

Create a new Project:

cargo new project-name

Add dependency by editing the Cargo.toml file:

[dependencies]
paho-mqtt = {git = "https://github.com/eclipse/paho.mqtt.rust", branch = "master"}
futures = { version = "0.3", features = ["compat"] }

Build the project:

cargo build

Run the program:

cargo run

Connect Device

Start connecting devices by following the guide :