Expand description
MQTT transport for the pamoja SDK.
MqttTransport implements the core Transport
trait on top of the pure-Rust rumqttc client, so an application can publish
to and subscribe from an MQTT broker through the same protocol-agnostic surface
it uses for every other transport.
Once connect succeeds the transport owns a background
task that drives the MQTT event loop: it answers keep-alive pings, completes
delivery handshakes, and forwards inbound messages to an internal queue that
recv drains. Publishing and subscribing use the
default QualityOfService configured on the transport.
§Examples
use pamoja_core::Transport;
use pamoja_mqtt::{MqttConfig, MqttTransport};
let mut transport = MqttTransport::new(MqttConfig::new("sensor-1", "localhost", 1883));
transport.connect().await?;
transport.subscribe("sensors/+/temperature").await?;
transport.send("sensors/1/temperature", b"21.5").await?;
if let Some(message) = transport.recv().await? {
println!("{}: {} bytes", message.topic, message.payload.len());
}Structs§
- Message
- A message received from a subscribed topic.
- Mqtt
Config - Connection settings for an
MqttTransport. - Mqtt
Transport - An MQTT client that implements the core
Transporttrait.
Enums§
- Quality
OfService - The delivery guarantee applied to published and subscribed messages.