Expand description
§MQTT Typed Client
§MQTT Typed Client
A type-safe async MQTT client built on top of rumqttc
Automatic topic routing and subscription management with compile-time guarantees
§The problem
Raw MQTT topics are stringly-typed. You hand-build them with format!(), split
them with split('/'), and deserialize payloads by hand — and the compiler
can’t help when you swap two segments or typo a prefix:
// rumqttc: easy to get wrong, fails silently at runtime
let topic = format!("sensors/{}/{}/data", location, device_id); // swapped order? compiler shrugs
let payload = serde_json::to_vec(&reading)?;
client.publish(topic, QoS::AtLeastOnce, false, payload).await?;With mqtt-typed-client the topic is a type. One derive turns the pattern into
a checked API — wrong order, wrong parameter type, or a typo won’t compile:
#[mqtt_topic("sensors/{location}/{device_id}/data")]
struct SensorTopic { location: String, device_id: u32, payload: SensorReading }
// generated, type-checked: device_id must be u32, order is fixed
client.sensor_topic().publish("kitchen", 42, &reading).await?;The bigger win is on the receiving side. Every rumqttc app grows the same hand-written dispatch loop:
// rumqttc: one loop, all routing by hand
while let Ok(event) = eventloop.poll().await {
if let Event::Incoming(Packet::Publish(p)) = event {
if p.topic.starts_with("sensors/") {
let parts: Vec<_> = p.topic.split('/').collect(); // parse, convert, dispatch...
} else if p.topic.starts_with("alerts/") {
// more of the same...
}
}
}Here each topic type gets its own subscriber and messages route to it
automatically. The loop, the starts_with, and the split('/') are gone:
let mut sensors = client.sensor_topic().subscribe().await?;
let mut alerts = client.alert_topic().subscribe().await?;
tokio::select! {
msg = sensors.receive() => { /* msg.device_id is already a u32 */ }
msg = alerts.receive() => { /* typed alert */ }
}§Key Features
- Topics as types — named parameters parsed/validated at compile time
- Typed parameters —
{device_id}can beu32,Uuid, or your own enum, not justString - Automatic routing — one broker stream fanned out to typed subscribers; the hand-written
poll()+match+starts_with(...)dispatch loop goes away - Reconnect that keeps subscriptions — automatic resubscribe on reconnect (happy path), graceful shutdown, LWT
- MQTT 5 — connect with protocol 5 for typed publish properties, request/response fields, and per-message v5 metadata (see MQTT 5 below)
MSRV: Rust 1.85.1 (driven by default bincode serializer; can be lowered with alternative serializers)
§Quick Start
Add the crate and the few deps the derive example needs:
[dependencies]
mqtt-typed-client = "0.4.0"
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
bincode = "2"
serdeis needed for theSerialize/Deserializederives andbincodefor the default serializer’sEncode/Decode. Switch serializers (e.g.json) and the derive requirements change accordingly.
use mqtt_typed_client::prelude::*;
use serde::{Deserialize, Serialize};
use bincode::{Encode, Decode};
#[derive(Serialize, Deserialize, Encode, Decode, Debug)]
enum SensorStatus {
Active,
Inactive,
Maintenance,
}
#[derive(Serialize, Deserialize, Encode, Decode, Debug)]
struct SensorReading {
temperature: f64,
status: SensorStatus, // enum field
location_note: String, // string field for variety
}
// Define typed topic with automatic parameter extraction
#[mqtt_topic("sensors/{location}/{device_id}/data")]
struct SensorTopic {
location: String, // String parameter
device_id: u32, // Numeric parameter - automatic conversion!
payload: SensorReading,
}
#[tokio::main]
async fn main() -> Result<()> {
// Connect to MQTT broker
let (client, connection) = MqttClient::<BincodeSerializer>::connect(
"mqtt://broker.hivemq.com:1883?client_id=demo_client"
).await?;
// Get typed client for this specific topic - method generated by macro
// Returns a typed client for publishing and subscribing to messages
// with automatic parameter handling for this topic pattern
let topic_client = client.sensor_topic();
// Subscribe to all matching topics: "sensors/+/+/data"
// Returns typed subscriber that automatically extracts and converts
// topic parameters into struct fields
let mut subscriber = topic_client.subscribe().await?;
let reading = SensorReading {
temperature: 22.5,
status: SensorStatus::Active,
location_note: "Kitchen sensor near window".to_string(),
};
// Publish with automatic type conversion to specific topic: "sensors/kitchen/42/data"
// Parameters are automatically converted to strings and inserted into topic pattern
let _ = topic_client.publish("kitchen", 42u32, &reading).await?;
// ^^^^^^^^ ^^^^^
// String u32 -> automatically converts to "42" in topic
// Receive with automatic parameter extraction and conversion
if let Some(ReceiveEvent::Message(msg)) = subscriber.receive().await {
println!("Device {} in location '{}' reported: temp={}°C, status={:?}",
msg.device_id, // u32 (converted from "42" in topic)
msg.location, // String (extracted from topic)
msg.payload.temperature, msg.payload.status);
}
connection.shutdown().await?;
Ok(())
}§MQTT 5
Connect with protocol 5 to send MQTT 5 PUBLISH properties. MQTT 3.1.1 stays the default; the v5 stack ships in the same crate with no MSRV or edition bump.
use mqtt_typed_client::{BincodeSerializer, MqttClient, PublishOptions};
use std::time::Duration;
// protocol=5 selects the v5 stack
let (client, connection) =
MqttClient::<BincodeSerializer>::connect("mqtt://broker:1883?protocol=5").await?;
// per-publish v5 properties via the builder
let opts = PublishOptions::builder()
.message_expiry(Duration::from_secs(60))
.content_type("application/json")
.response_topic("replies/abc") // request/response building block
.user_property("trace-id", "xyz")
.build();
client.sensor_topic().publish_with("kitchen", 42u32, &reading, opts).await?;On a v4 connection a publish carrying any v5 property is rejected with a typed
CapabilityError::RequiresV5, never silently dropped. Inbound v5 properties are
exposed via Mqtt5Meta on the received message.
§Typed request/response (RPC)
Declare a reply type once and get a typed call / serve pair — the v5
response_topic + correlation_data plumbing is handled for you:
#[mqtt_topic("devices/{device_id}/rpc/get_temp", response = TempReply)]
struct GetTemp { device_id: String, payload: TempQuery }
// caller (v5 connection required)
let rpc = client.rpc().await?;
let reply: TempReply = rpc.get_temp().call("sensor-42", &query).await?;
// server: `serve` runs the loop and publishes the reply — the handler just
// returns it (a pull `responder()` / `receive()` API is also available)
client.get_temp().serve(|req: GetTemp| async move {
TempReply { value: read_sensor(&req.device_id).await }
}).await?;Remote application errors are the reply type’s own concern —
response = Result<Reply, MyError> — distinct from RequestError (timeout /
transport / decode). Scale a service across N instances by running each with
serve_shared("group", handler) — MQTT 5 shared subscriptions load-balance
requests across the group (requires a v5 connection). See
examples/011_rpc_request_response.rs and examples/015_rpc_serve_shared.rs.
More v5 is tracked in docs/ROADMAP_v5.md.
§Examples
See examples/ - Complete usage examples with source code
000_hello_world.rs- Basic publish/subscribe with macros001_ping_pong.rs- Multi-client communication002_configuration.rs- Advanced client configuration003_hello_world_lwt.rs- Last Will & Testament004_hello_world_tls.rs- TLS/SSL connections005_hello_world_serializers.rs- Custom serializers006_retain_and_clear.rs- Retained messages007_custom_patterns.rs- Custom topic patterns008_modular_example.rs- Modular application structure009_message_metadata.rs- Per-message metadata (QoS, retain, dup)010_connection_state.rs- Observing the connection lifecycle011_rpc_request_response.rs- Typed request/response (RPC) over MQTT 5012_mqtt5_properties.rs- MQTT 5 publish properties and reading v5 metadata013_subscribe_options.rs- MQTT 5 subscribe options (no-local, retain handling)014_shared_subscriptions.rs- MQTT 5 shared subscriptions ($share)015_rpc_serve_shared.rs- Scaled typed RPC service (serve_shared)016_custom_payload_formats.rs- Interop with bare text/compound/byte payloads (TextSerializer/RawBytesSerializer)100_all_serializers_demo.rs- All serializers side by side102_multi_serializer_macro.rs- Per-topic custom serializers
Run examples:
cargo run --example 000_hello_world§Serialization Support
Multiple serialization formats are supported via feature flags:
bincode- Binary serialization (default, most efficient)json- JSON serialization (default, human-readable)messagepack- MessagePack binary formatcbor- CBOR binary formatpostcard- Embedded-friendly binary formatron- Rusty Object Notationflexbuffers- FlatBuffers FlexBuffersprotobuf- Protocol Buffers (requires generated types)
Two more serializers are always available (they pull no extra dependency), so they need no feature flag:
TextSerializer- bareDisplay/FromStrpayloads (numbers, tokens, compounds)RawBytesSerializer- opaque byte pass-through (Vec<u8>/Bytes)
Enable additional (feature-gated) serializers:
[dependencies]
mqtt-typed-client = { version = "0.4.0", features = ["messagepack", "cbor"] }Custom serializers can be implemented by implementing the MessageSerializer trait.
Choosing a serializer:
- Interop with an existing (non-Rust) system →
TextSerializer/RawBytesSerializer. Payloads are bare values (21.5,ON, Homie255,0,0, raw bytes), not framed structs — JSON would quote strings ("21.5") and bincode would length-prefix, so neither round-trips. - Performance / embedded / no_std →
bincode,postcard. - Human-readable →
json,ron.
Interop tip.
TextSerializeris a blanket over anyT: Display + FromStr— the same machinery topic parameters already use — soString, numbers,bool, and your own comma-separatedColor/Coordtypes all round-trip as bare text. See016_custom_payload_formats.rsfor a worked example (Homie color, baref64, string token, raw-byte tunnel).
§Per-Topic Serializer Override
By default every topic uses the client’s serializer. You can override it for a specific topic type — handy for legacy formats or gradual migrations:
use mqtt_typed_client_macros::mqtt_topic;
// This topic always uses JSON, regardless of the client's default serializer.
#[mqtt_topic("legacy/devices/{id}/status", serializer = JsonSerializer)]
struct LegacyStatus {
id: u32,
payload: DeviceStatus,
}The generated typed client works for custom-serializer topics too —
client.legacy_status()... publishes/subscribes as usual; the facade swaps in
the concrete serializer internally (via clone_with_serializer), so you keep the
ergonomic surface, not just the low-level API.
Limitation:
- Only a simple type path is accepted for
serializer = .... For a generic serializer, declare a type alias first:type MySer = MySerializer<Foo>;then useserializer = MySer.
§Topic Pattern Matching
Supports MQTT wildcard patterns with named parameters:
{param}- Named parameter (equivalent to+wildcard){param:#}- Multi-level named parameter (equivalent to#wildcard)
use mqtt_typed_client_macros::mqtt_topic;
// Traditional MQTT wildcards
#[mqtt_topic("home/+/temperature")] // matches: home/kitchen/temperature
struct SimplePattern { payload: f64 }
// Named parameters (recommended)
#[mqtt_topic("home/{room}/temperature")] // matches: home/kitchen/temperature
struct NamedPattern {
room: String, // Automatically extracted: "kitchen"
payload: f64
}
// Multi-level parameters
#[mqtt_topic("logs/{service}/{path:#}")] // matches: logs/api/v1/users/create
struct LogPattern {
service: String, // "api"
path: String, // "v1/users/create"
payload: String // Changed from Data to String
}§Runtime Pattern Override
The pattern in #[mqtt_topic("...")] is the default, but you can override it at
runtime — as long as the parameter set (same names and types) stays the same. Only the
literal segments and prefix may differ. Handy when the topic layout is decided at deploy
time rather than compile time: environment prefixes, multi-tenant tenancy, or legacy
formats. The override is validated when you call it (fast-fail on a parameter mismatch).
// declared once: #[mqtt_topic("greetings/{language}/{sender}")]
// Subscribe with an environment prefix from config:
let mut subscriber = client.greeting_topic()
.subscription()
.with_pattern("dev/greetings/{language}/{sender}")? // ✅ same {language}, {sender}
.subscribe()
.await?;
// Publish to a multi-tenant layout:
let publisher = client.greeting_topic()
.get_publisher_to("tenant_42/greetings/{language}/{sender}", "rust", "alice")?;
publisher.publish(&message).await?;
// Last Will with a custom pattern:
let lwt = GreetingTopic::last_will_to(
"dev/greetings/{language}/{sender}", "rust", "client", lwt_message,
)?;
// ❌ Rejected — different parameter names:
// .with_pattern("greetings/{room}/{device_id}")Parameter reordering (same set, different order) is not accepted yet — tracked in
#4. See
examples/007_custom_patterns.rs
for a full runnable example.
§TLS and Transport
Transport security and extras are opt-in via feature flags:
| Feature | Effect |
|---|---|
tls-rustls (default) | TLS via rustls with the aws-lc-rs provider |
tls-rustls-no-provider | rustls without a bundled crypto provider — bring your own (e.g. ring) and avoid the aws-lc build |
tls-native | Compile in the platform’s native-tls (reachable via the backend escape hatch for now) |
websocket | MQTT over WebSocket |
proxy | Connect through an HTTP/HTTPS proxy |
(The 0.2 rumqttc-* feature names are gone as of 0.4, as 0.3 announced when it
deprecated them. Use the names above; rumqttc-url has no successor — URL
parsing is built in.)
§MQTT backend
The MQTT stack underneath is chosen at compile time by a backend-* feature.
Exactly one must be enabled — enabling none or both is a compile error with a
message saying so.
| Feature | Backend |
|---|---|
backend-rumqttc (default) | upstream rumqttc — the supported choice |
backend-rumqttc-next | the maintained fork (rumqttc-v4-next / rumqttc-v5-next) — experimental, requires Rust 1.89 |
Since backend-rumqttc is a default feature, picking the other one means
turning defaults off:
mqtt-typed-client = { version = "0.4.0", default-features = false,
features = ["backend-rumqttc-next", "macros", "json"] }The typed client API is the same either way — topics, publish, subscribe, RPC
and options name no backend type. The exceptions are the deliberate escape
hatches: QoS::to_rumqttc() / to_rumqttc_v5() (and From<rumqttc::QoS>) exist
only under backend-rumqttc, and the semver-exempt unstable-backend-api
surface has by definition the shape of whichever backend is selected. Beyond
those, the fork’s extra facilities (manual acks, publish tracking) are not yet
reachable through this crate’s API, so there is no reason to switch unless you
are helping to exercise the second backend.
For custom TLS setups you can build the rustls config yourself. The crate
re-exports the backend’s rustls (version-matched, so you don’t add a
separate rustls dependency that could drift out of sync):
use mqtt_typed_client::rustls::{ClientConfig, RootCertStore};
let mut root_store = RootCertStore::empty();
// Add your trusted roots to `root_store` here (e.g. parsed from a PEM file).
ClientConfig::builder()
.with_root_certificates(root_store)
.with_no_client_auth()See examples/004_hello_world_tls.rs for a complete TLS example,
including loading a CA certificate from a PEM file.
§Advanced Usage: Low-Level API
For cases where you need direct control without macros:
use mqtt_typed_client::prelude::*;
use serde::{Deserialize, Serialize};
use bincode::{Encode, Decode};
#[derive(Serialize, Deserialize, Encode, Decode, Debug)]
struct SensorData {
temperature: f64,
humidity: f64,
}
#[tokio::main]
async fn main() -> Result<()> {
let (client, connection) = MqttClient::<BincodeSerializer>::connect(
"mqtt://broker.hivemq.com:1883?client_id=demo_client"
).await?;
// Direct topic operations
let publisher = client.get_publisher::<SensorData>("sensors/temperature")?;
let mut subscriber = client.subscribe::<SensorData>("sensors/+").await?;
let data = SensorData { temperature: 23.5, humidity: 45.0 };
let _ = publisher.publish(&data).await?;
match subscriber.receive().await {
Some(ReceiveEvent::Message(msg)) => {
println!("Received from {} (qos {:?}): {:?}",
msg.topic.topic_path(), msg.meta.qos, msg.payload)
}
Some(ReceiveEvent::DecodeFailed(f)) => {
eprintln!("Deserialization error at {}: {:?}", f.topic.topic_path(), f.error)
}
Some(ReceiveEvent::Lagged { missed }) => {
eprintln!("Lagged: {} messages dropped", missed)
}
_ => {}
}
connection.shutdown().await?;
Ok(())
}§What mqtt-typed-client adds over rumqttc
Publishing:
// rumqttc - manual topic construction and serialization
let sensor_id = "sensor001";
let data = SensorData { temperature: 23.5 };
let topic = format!("sensors/{}/temperature", sensor_id);
let payload = serde_json::to_vec(&data)?;
client.publish(topic, QoS::AtLeastOnce, false, payload).await?;
// mqtt-typed-client - type-safe, automatic
topic_client.publish(&sensor_id, &data).await?;Subscribing with routing: see The problem above. The
eventloop.poll() dispatch loop is replaced by per-topic typed subscribers.
For a detailed comparison see: docs/COMPARISON_WITH_RUMQTTC.md
§Alternatives
- rumqttc — the async MQTT client this crate builds on. Use it directly when you want full manual control over topics, serialization, and the event loop.
- paho-mqtt — Rust bindings to the Eclipse Paho C client; a fit when you need that mature C library or its feature set.
- ntex-mqtt — MQTT client and server built on the ntex framework; worth a look if you’re already in that ecosystem or need a broker.
Reach for mqtt-typed-client when you want typed topic routing and automatic
(de)serialization on top of rumqttc, without hand-writing the dispatch layer.
It is a layer over rumqttc, not a replacement: if your app handles one or two
topics and you want to drive the event loop yourself, raw rumqttc is less machinery.
§License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
§Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
See CONTRIBUTING.md for detailed guidelines.
§API Reference
For detailed API documentation, visit docs.rs/mqtt-typed-client.
§See Also
- rumqttc - The underlying MQTT client library
- MQTT Protocol Specification - Official MQTT documentation
- Rust Async Book - Guide to async Rust programming
§API Reference
Key traits and modules:
MessageSerializer- Custom serialization traitprelude- Convenient imports for common use casesinfo- Library metadata and version info
§See Also
crate::comparison- Detailed comparison with rumqttccrate::examples- Complete usage examples with source code
Modules§
- _macro_
docs - Procedural Macros
- advanced
- Advanced types and utilities for complex use cases
- backend
- Backend-specific code. Everything that names a backend crate’s types lives here; the rest of the crate works in neutral facade types. Everything that knows about a concrete MQTT backend crate.
- client
- MQTT client module
- comparison
- Detailed comparison with rumqttc
- connection
- MQTT connection management module
- connection_
state - Observable connection lifecycle state.
- errors
- Error types used throughout the library
- examples
- Complete usage examples with source code
- info
- Library metadata and version information
- message_
meta - Per-message MQTT metadata surfaced to subscribers.
- message_
serializer - Message serialization traits and implementations.
- prelude
- Convenient imports for common use cases
- routing
- Message routing and subscription management module
- structured
- Structured MQTT subscribers with automatic topic parameter extraction
- topic
- Topic handling module - re-exported from mqtt-topic-engine
Structs§
- Bincode
Serializer - Default serializer using bincode format.
- Call
Options - Per-call options for
call_with. - Call
Options Builder - Builder for
CallOptions. - Cbor
Serializer - CBOR serializer using ciborium.
- Client
Settings - Client-level performance and behavior settings for the MQTT typed client.
- Connection
Options - Protocol-neutral MQTT connection options.
- Credentials
- Username/password pair sent in the MQTT CONNECT packet.
- Decode
Failure - A message arrived but its payload could not be deserialized. Carries the same
context as
IncomingMessageso a handler can still see which topic (and with what metadata) failed. The stream continues after this event. - Flexbuffers
Serializer - Flexbuffers serializer using flexbuffers crate.
- Incoming
Message - A successfully delivered message: its decoded payload plus the context that
arrived with it.
topicandmetaare shared (Arc) across every subscriber of the same publish;payloadis this subscriber’s own decoded value. - Json
Serializer - JSON serializer using serde_json.
- Message
Meta - Protocol metadata attached to an incoming MQTT message.
- Message
Pack Serializer - MessagePack serializer using rmp-serde.
- Mqtt5
AckMeta - MQTT 5 acknowledgement properties (PUBACK/PUBREC).
- Mqtt5
Meta - MQTT 5 message properties, attached to an incoming message via
MessageMeta::v5. AlwaysNoneon MQTT 3.1.1. - Mqtt
Client - Type-safe MQTT client with automatic subscription management.
- Mqtt
Client Config - Configuration for MQTT client creation
- Mqtt
Connection - MQTT connection handle for lifecycle management
- Mqtt
Publisher - Typed MQTT publisher for a specific topic.
- Mqtt
RpcCaller - A client set up as an RPC requester: it owns a unique response-topic subscription and the in-flight-request registry.
- Mqtt
RpcResponder - A typed RPC responder: subscribes to the request topic and yields reply-capable requests.
- Mqtt
Subscriber - Typed MQTT subscriber for topic patterns.
- Mqtt
Topic Subscriber - Structured MQTT subscriber with automatic topic parameter extraction.
- Pending
Reply - An in-flight RPC call: its correlation token plus the channel that resolves when the reply arrives. Dropping it (on completion, timeout, or cancellation) removes its registry entry.
- Postcard
Serializer - Postcard serializer using postcard crate.
- Protobuf
Serializer - Protocol Buffers serializer using prost crate.
- Publish
Options - Per-publish options for
MqttPublisher::publish_with. - Publish
Options Builder - Builder for
PublishOptions. Only the fields with a setter here are ACTIVE in 0.4;topic_aliasis reserved (no setter). - Publish
Outcome - The result of a publish.
#[non_exhaustive]so v5 ack details can be surfaced additively. - Publish
Receipt - The outcome of a publish, returned by every
publish*call. - Publish
Receipt Future - The future obtained by awaiting a
PublishReceipt. - RawBytes
Serializer - Identity serializer for opaque byte payloads.
- Reply
Address - The private reply address of an RPC request: the requester’s response topic and correlation token, plus the client to publish through.
- RonSerializer
- RON (Rusty Object Notation) serializer using ron crate.
- RpcOptions
- Per-caller RPC configuration, passed to
MqttClient::rpc_with. - RpcOptions
Builder - Builder for
RpcOptions. - RpcRequest
- A received RPC request, carrying the decoded topic struct and a private
reply address. Derefs to the topic struct
MessageT(its topic params and payload), sorequest.device_id/request.payloadread through. - Rustls
Client Config - Opaque holder for a rustls client configuration.
- Serve
Options - Configuration for a
serve/serve_sharedRPC service, passed toMqttRpcResponder::serve_with. - Serve
Options Builder - Builder for
ServeOptions. - Share
Group - A validated MQTT 5 shared-subscription group name — the
<ShareName>in$share/<ShareName>/<filter>. - Subscribe
Options - MQTT 5 per-
Filtersubscription options. - Subscription
Builder - Immutable builder for configuring MQTT subscriptions.
- Subscription
Config - Per-subscription delivery configuration.
- Subscription
Grant - A subscription the broker accepted, with the QoS it actually granted (which may be a downgrade from what we requested).
- Subscription
Loss - A subscription the broker rejected (or later dropped), with the reason.
- Text
Serializer - Text serializer for bare
Display/FromStrpayloads. - Topic
Pattern Path - Parsed MQTT topic pattern with wildcard support
- Typed
Last Will - Represents a Last Will and Testament (LWT) message for MQTT clients.
Enums§
- Cache
Strategy - Strategy for caching topic matching results
- Connection
State - The connection’s current lifecycle state.
- Disconnect
Reason - Why the connection reached its terminal
ConnectionState::Disconnected. - Disconnect
Reason Code - MQTT 5 DISCONNECT reason code, surfaced on
DisconnectReason::BrokerDisconnected. - Message
Conversion Error - Errors that occur during message conversion from MQTT topics.
- Mqtt
Client Error - Errors that can occur in MQTT client operations
- Payload
Format - How an MQTT 5 PUBLISH payload is meant to be interpreted (the Payload Format
Indicator). Shared by the receive-side
Mqtt5Metaand the publish options. - Protocol
Version - MQTT protocol version to speak on the wire.
- PubReason
Code - A publish reason code (MQTT 5 PUBACK/PUBREC).
#[non_exhaustive]: onlySuccessis ever produced in 0.4; the broker-reported failure codes are RESERVED for the addressable-ack track. - QoS
- MQTT Quality of Service levels
- Receive
Event - Outcome of a single
receive()/recv()call. - Request
Error - Failure of one RPC call, as seen by the requester.
- Retain
Handling - When the broker forwards retained messages for a new subscription (MQTT 5). The backend maps this to its own retain-forwarding wire rule.
- Session
Policy - What happens to the MQTT session across connections.
- SubReason
Code - Reason a subscription was rejected by the broker (the failure half of a
SUBACK reason code —
Successis aSubscriptionGrant, not a loss). - Text
Deserialize Error - Deserialization failure for
TextSerializer: the payload was not UTF-8, orFromStrrejected the text. - TlsConfig
- TLS configuration for encrypted transports.
- Topic
Error - Comprehensive error type for all topic-related operations
- Topic
Pattern Error - Error types for topic pattern parsing
- Transport
- Network transport for the MQTT connection.
Constants§
Traits§
- From
Mqtt Message - Trait for converting MQTT messages into structured types.
- Message
Serializer - Trait for serializing and deserializing MQTT message payloads.
Functions§
- extract_
topic_ parameter - Extract and parse a topic parameter by wildcard index
Type Aliases§
- Result
- Result type alias for operations that may fail with MqttClientError
- RpcEvent
- Event yielded by
MqttRpcResponder::receive: a reply-capableRpcRequeston success, reusing the shippedReceiveEventvocabulary soDecodeFailed/Laggedflow through unchanged.
Attribute Macros§
- mqtt_
topic - Generate a typed MQTT subscriber and/or publisher from a struct and topic pattern