| Crates.io | rust-mqtt |
| lib.rs | rust-mqtt |
| version | 0.4.1 |
| created_at | 2022-04-28 12:30:19.283015+00 |
| updated_at | 2026-01-06 11:03:27.889351+00 |
| description | MQTT client for embedded and non-embedded environments |
| homepage | |
| repository | https://github.com/obabec/rust-mqtt |
| max_upload_size | |
| id | 576767 |
| size | 416,705 |
rust-mqtt is an MQTT client primarily for no_std environments. The library provides an async API depending on embedded_io_async's traits. As of now, only MQTT version 5.0 is supported.
Read::read very frequently.log: Enables logging via the log cratedefmt: Implements defmt::Format for crate items & enables logging via the defmt crate (version 1)bump: Adds a simple bump allocator BufferProvider implementationalloc: Adds a heap-allocation based BufferProvider implementation using the alloc cratev3: Unusedv5: Enables MQTT version 5.0Set up the broker for 'demo' by installing, configuring and running Mosquitto using the CI configuration:
cp .ci/mqtt_pass_plain.txt .ci/mqtt_pass_hashed.txt
chmod 700 .ci/mqtt_pass_hashed.txt
mosquitto_passwd -U .ci/mqtt_pass_hashed.txt
mosquitto -c .ci/mosquitto.conf -v
Set up the broker for 'tls' by running Mosquitto with the tls config file. The required PKI files have been generated using the .ci/pki/generate.sh script.
mosquitto -c .ci/mosquitto-tls.conf -v
Then you can run the examples with different logging configs and the bump/alloc features:
RUST_LOG=debug cargo run --example demo
RUST_LOG=info cargo run --example tls
RUST_LOG=trace cargo run --example demo --no-default-features --features "v5 log bump"
Unit tests should be ran using both the 'alloc' and 'bump' features.
cargo test unit
cargo test unit --no-default-features --features "v5 bump"
For integration tests, you can set up the mosquitto broker as used in the CI pipeline. You should restart the broker after every run of the integration test suite as it carries non-idempotent state that will impact the tests.
cp .ci/mqtt_pass_plain.txt .ci/mqtt_pass_hashed.txt
chmod 700 .ci/mqtt_pass_hashed.txt
mosquitto_passwd -U .ci/mqtt_pass_hashed.txt
mosquitto -c .ci/mosquitto.conf [-d]
Then you can run integration tests with the alloc feature.
cargo test integration
It can be helpful to see logging output when running tests.
RUST_LOG=trace cargo test unit --no-default-features --features "v5 bump" -- --show-output
RUST_LOG=warn cargo test -- --show-output
RUST_LOG=info cargo test integration -- --show-output
The full test suite can run with the alloc feature, just make sure a fresh broker is up and running.
cargo test
This project could not be in state in which currently is without Ulf Lilleengen and the rest of the community from Drogue IoT.
For any information, open an issue if your matter could be helpful or interesting for others or should be documented. Otherwise contact us on email julian.jg.graf@gmail.com, ond.babec@gmail.com.