mqtt-service
This crate provides a convenient support for the MQTT Response-Pattern. It uses the rumqttc library to connect to the MQTT broker.
Note: this crate is feature complete, and few changes are expected.
How to use
Add mqtt-service, mqtt-client and tokio to your project:
mqtt-service needs a tokio runtime and a mqtt_channel::Client:
let rt = new.unwrap;
let = build
.start;
rt.spawn;
Then a mqtt-service client can be created:
let client = new;
Then you can create a JSON service with:
rt.spawn;
Alternatively, you can use create_raw_service for higher control on the serialization of message. Then the service can be called using call_json_service (or call_raw_service):
let fut = connection
.
.unwrap;
let res = rt.block_on.unwrap;
Compatibility
| rumqttc | mqtt-channel |
|---|---|
| 0.25 | 0.7 |
| 0.24 | 0.1-0.6 |