Skip to main content

Crate ebus_mqtt

Crate ebus_mqtt 

Source
Expand description

MQTT vocabulary for eBus.

The messages and commands the Homie state machines exchange with an MQTT client, topic filter matching, and, with alloc, the FilterLedger that tracks which subscriptions the client holds and who may remove them, the Role trait those state machines implement, and Pair, which runs two of them on one link.

The crate performs no I/O and reads no clock: time arrives as an Instant the caller supplies, received messages arrive as Messages, and work for the MQTT client leaves as Commands.

use ebus_mqtt::filter;

assert!(filter::matches("ebus/5/+/$state", "ebus/5/meter-1/$state"));
assert!(filter::matches("ebus/5/meter-1/#", "ebus/5/meter-1/power/watts"));
// A leading wildcard does not match a topic that starts with `$`.
assert!(!filter::matches("+/5/meter-1/$state", "$SYS/5/meter-1/$state"));

§Features

Modules§

filter
Topic names and topic filters, per MQTT 3.1.1 section 4.7.

Structs§

FilterLedgeralloc
Refcounts per filter string, so that the subscriptions several holders share are subscribed once and unsubscribed only when the last holder lets go.
Instant
Milliseconds on the caller’s monotonic clock.
LastWillalloc
The Last Will and Testament a client registers when it connects.
Message
A message received from the broker, borrowed from the client’s buffer.
Pairalloc
Two roles on one link.

Enums§

Commandalloc
Work for the MQTT client.
Handled
Whether a role took a received message.
Link
A change in the state of the connection to the broker.
QoS
MQTT quality of service level.
Receiptalloc
A broker or client report on a command already sent, for a host that tracks delivery (a device built with TreeConfig::receipts).

Traits§

Rolealloc
One protocol role on an MQTT link: a sans-IO state machine fed with link changes, messages and the caller’s time, and drained of commands.