Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
000b8c3
allow topic alias for incoming PUBLISH packets
julian-graf Sep 11, 2026
d5b9302
make topic reference getters public
julian-graf Sep 11, 2026
b0c5ae9
fix tests
julian-graf Sep 11, 2026
5ffc960
add missing assert_ne import
julian-graf Sep 12, 2026
8dc7111
add tracking of existing topic alias mappings
julian-graf Sep 12, 2026
970d8ae
add unit tests for tracking of topic alias mappings
julian-graf Sep 12, 2026
07b765b
fix examples
julian-graf Sep 12, 2026
d92b24a
fix integration tests
julian-graf Sep 12, 2026
45c93e1
add integration test for incoming topic alias
julian-graf Sep 12, 2026
b87dc9b
document changes
julian-graf Sep 12, 2026
fce7fdb
add topic alias maximum integration test
julian-graf Sep 12, 2026
b4092c3
fix format
julian-graf Sep 12, 2026
fba1d28
disable incoming topic alias tests for hivemq
julian-graf Sep 12, 2026
bf3d3b4
fix msrv
julian-graf Sep 12, 2026
c83acc3
fix logging inconsistencies in sub/unsub
julian-graf Sep 13, 2026
d4b5e4f
fix inconsistencies in reason code checks in client and packet decoding
julian-graf Sep 13, 2026
6a02f39
document change
julian-graf Sep 13, 2026
7f07eee
document ordered topic conditions and guarantees
julian-graf Sep 20, 2026
f2c2cfa
enable tests for emqx with version 6.3.0
julian-graf Sep 4, 2026
bae10b3
update emqx version in CI to 6.3.0
julian-graf Sep 4, 2026
a5f2d50
enable test for emqx with version 6.3.1
julian-graf Sep 20, 2026
8a19360
update emqx version in CI to 6.3.1
julian-graf Sep 20, 2026
42344c5
fix small errors
julian-graf Sep 20, 2026
e15ed5d
add s
julian-graf Sep 21, 2026
5cc5e3d
fix unused warning in example
julian-graf Sep 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/integration_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ jobs:
-p 18083:18083 \
-v $PWD/.ci/emqx.conf:/opt/emqx/etc/emqx.conf \
-v $PWD/.ci/emqx_users.csv:/opt/emqx/etc/auth-built-in-db-bootstrap.csv \
emqx/emqx:6.2.2
timeout 30s sh -c 'until docker logs emqx 2>&1 | grep "EMQX Enterprise 6.2.2 is running now!"; do sleep 0.1; done'
emqx/emqx:6.3.1
timeout 30s sh -c 'until docker logs emqx 2>&1 | grep "EMQX Enterprise 6.3.1 is running now!"; do sleep 0.1; done'

API_JSON=$(docker exec emqx emqx ctl api_keys add --api-secret abcdefghijklmnopqrstuvwxyz0123456789 --name admin)
API_KEY=$(echo $API_JSON | grep -o '"api_key" : "[^"]*"' | cut -d'"' -f4)
Expand All @@ -142,8 +142,8 @@ jobs:
-p 18083:18083 \
-v $PWD/.ci/emqx.conf:/opt/emqx/etc/emqx.conf \
-v $PWD/.ci/emqx_users.csv:/opt/emqx/etc/auth-built-in-db-bootstrap.csv \
emqx/emqx:6.2.2
timeout 30s sh -c 'until docker logs emqx 2>&1 | grep "EMQX Enterprise 6.2.2 is running now!"; do sleep 0.1; done'
emqx/emqx:6.3.1
timeout 30s sh -c 'until docker logs emqx 2>&1 | grep "EMQX Enterprise 6.3.1 is running now!"; do sleep 0.1; done'

API_JSON=$(docker exec emqx emqx ctl api_keys add --api-secret abcdefghijklmnopqrstuvwxyz0123456789 --name admin)
API_KEY=$(echo $API_JSON | grep -o '"api_key" : "[^"]*"' | cut -d'"' -f4)
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Return the `Transport` network handle after a successful disconnection / abortion
- Add enhanced authentication with `Client::connect_enhanced` and re-authentication with `Client::reauthenticate`
- Add generic paramater to `MqttError` defaulting to `Infallible` for errors during enhanced authentication
- Add const generic parameter `MAX_INCOMING_TOPIC_ALIASES` indicating the number of topic aliases that are supported in inbound direction
- Add const generic parameter `MAX_OUTGOING_TOPIC_ALIASES` indicating the number of topic aliases that are supported in outbound direction
- Pass through the complete `TopicReference` instead of only the `TopicName` in incoming publications
- Prevent publications by the client without a topic name to topic aliases that have not been mapped before
- Detect protocol error on DISCONNECT packet by the server with client-only reason code

## 0.5.1 - 2026-04-10

Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ The design goal is a strict yet flexible and explicit API that leverages Rust's

## Library state

The MQTT client is feature complete against the MQTTv5 specification.

### Supported MQTT features

- Will
Expand All @@ -31,17 +33,17 @@ The design goal is a strict yet flexible and explicit API that leverages Rust's
- Subscription identifiers
- Shared & wildcard subscriptions
- Message expiry interval
- Topic alias in outgoing publications
- Topic alias
- Request/Response
- Request Problem Information
- Reason String
- User Property
- Enhanced/Extended authentication and re-authentication

### Currently unsupported MQTT features & limitations
### Current limitations

- Subscribing to multiple topics in a single packet
- Topic alias in incoming publications
- Subscribing to multiple topics in a single packet is not supported
- [Ordered topic guarantees](https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901240) are not built into the client, as implementing them introduces significant overhead and adds unnecessary complexity for simple use cases. The exact rules required for specification-compliant usage of `rust-mqtt` are documented in the [`Client` methods documentation](https://docs.rs/rust-mqtt/latest/rust_mqtt/client/struct.Client.html). However, if only a single packet identifier is in flight concurrently, these restrictions do not apply.

### Extension plans (more or less by priority)

Expand Down
2 changes: 1 addition & 1 deletion examples/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async fn main() {

let mut buffer = AllocBuffer;

let mut client = Client::<'_, '_, _, _, 1, 1, 1, 1, 16>::new(&mut buffer);
let mut client = Client::<'_, '_, _, _, 1, 1, 1, 1, 16, 0, 0>::new(&mut buffer);

let addr = SocketAddr::new(Ipv4Addr::LOCALHOST.into(), 1883);
let connection = TcpStream::connect(addr).await.unwrap();
Expand Down
5 changes: 3 additions & 2 deletions examples/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async fn main() {
#[cfg(feature = "bump")]
let mut buffer = BumpBuffer::new(&mut buffer);

let mut client = Client::<'_, '_, _, _, 1, 1, 1, 1, 16>::new(&mut buffer);
let mut client = Client::<'_, '_, _, _, 1, 1, 1, 1, 16, 0, 1>::new(&mut buffer);

let addr = SocketAddr::new(Ipv4Addr::LOCALHOST.into(), 1883);
let connection = TcpStream::connect(addr).await.unwrap();
Expand Down Expand Up @@ -269,7 +269,8 @@ async fn main() {
let mut buffer = BumpBuffer::new(&mut buffer);

// Continue the previous session
let mut client = Client::<'_, '_, _, _, 1, 1, 1, 1, 16>::with_session(session, &mut buffer);
let mut client =
Client::<'_, '_, _, _, 1, 1, 1, 1, 16, 0, 1>::with_session(session, &mut buffer);

let addr = SocketAddr::new(Ipv4Addr::LOCALHOST.into(), 1883);
let connection = TcpStream::connect(addr).await.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions examples/manual_ack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async fn main() {
#[cfg(feature = "bump")]
let mut buffer = BumpBuffer::new(&mut buffer);

let mut client = Client::<'_, '_, _, _, 1, 3, 3, 0, 16>::new(&mut buffer);
let mut client = Client::<'_, '_, _, _, 1, 3, 3, 0, 16, 0, 0>::new(&mut buffer);

// Acknowledge all packets manually which have a payload format indicator property with a value of
// true (claiming that the payload is UTF-8). We intentionally leave the check for actual UTF-8
Expand Down Expand Up @@ -162,7 +162,7 @@ async fn main() {
let h = assert_ok!(header);
match assert_ok!(client.poll_body(h).await) {
// Outgoing publications & their acknowledgement counterpart
Event::PublishReceived(Puback { ack_mode: AckMode::Manual, packet_identifier, reason_code, reason_string, user_properties }) if reason_code.is_success() => {
Event::PublishReceived(Puback { ack_mode: AckMode::Manual, packet_identifier, reason_code, .. }) if reason_code.is_success() => {
info!("Manually releasing packet identifier {packet_identifier}");
client.manual_release(packet_identifier, &AckOptions::new().reason_string(MqttString::from_str("s").unwrap())).await.unwrap();
}
Expand Down
2 changes: 1 addition & 1 deletion examples/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async fn main() {
#[cfg(feature = "bump")]
let mut buffer = BumpBuffer::new(&mut buffer);

let mut client = Client::<'_, '_, _, _, 1, 1, 1, 0, 1>::new(&mut buffer);
let mut client = Client::<'_, '_, _, _, 1, 1, 1, 0, 1, 0, 0>::new(&mut buffer);

let addr = SocketAddr::new(Ipv4Addr::LOCALHOST.into(), 8883);
let connection = TcpStream::connect(addr).await.unwrap();
Expand Down
11 changes: 11 additions & 0 deletions src/client/err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ pub enum Error<'e, const MAX_USER_PROPERTIES: usize, A = Infallible> {
/// [`Event::PublishComplete`]: crate::client::event::Event::PublishComplete
SendQuotaExceeded,

/// A publish without a topic name was attempted to a topic alias that has not been mapped previously.
/// This can only occur when [`TopicReference::Alias`] is used.
///
/// Recoverable error. No action has been taken by the client.
///
/// [`TopicReference::Alias`]: crate::client::options::TopicReference::Alias
TopicAliasNotMapped,

/// An operation was attempted which the server stated it does not support. If the requested operation
/// were executed as is, a protocol error would be caused.
///
Expand Down Expand Up @@ -289,6 +297,7 @@ impl<const MAX_USER_PROPERTIES: usize, A> Error<'_, MAX_USER_PROPERTIES, A> {
| Self::ServerMaximumPacketSizeExceeded
| Self::SessionBuffer
| Self::SendQuotaExceeded
| Self::TopicAliasNotMapped
| Self::UnsupportedByServer
| Self::IllegalNoLocalSharedSubscription
| Self::NoEnhancedAuthentication
Expand Down Expand Up @@ -332,6 +341,7 @@ impl<'e, A> Error<'e, 0, A> {
Self::ServerMaximumPacketSizeExceeded => Error::ServerMaximumPacketSizeExceeded,
Self::SessionBuffer => Error::SessionBuffer,
Self::SendQuotaExceeded => Error::SendQuotaExceeded,
Self::TopicAliasNotMapped => Error::TopicAliasNotMapped,
Self::UnsupportedByServer => Error::UnsupportedByServer,
Self::IllegalNoLocalSharedSubscription => Error::IllegalNoLocalSharedSubscription,
Self::NoEnhancedAuthentication => Error::NoEnhancedAuthentication,
Expand Down Expand Up @@ -376,6 +386,7 @@ impl<'e, const MAX_USER_PROPERTIES: usize> Error<'e, MAX_USER_PROPERTIES> {
Self::ServerMaximumPacketSizeExceeded => Error::ServerMaximumPacketSizeExceeded,
Self::SessionBuffer => Error::SessionBuffer,
Self::SendQuotaExceeded => Error::SendQuotaExceeded,
Self::TopicAliasNotMapped => Error::TopicAliasNotMapped,
Self::UnsupportedByServer => Error::UnsupportedByServer,
Self::IllegalNoLocalSharedSubscription => Error::IllegalNoLocalSharedSubscription,
Self::NoEnhancedAuthentication => Error::NoEnhancedAuthentication,
Expand Down
9 changes: 6 additions & 3 deletions src/client/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use heapless::Vec;

use crate::{
bytes::Bytes,
client::AckMode,
client::{AckMode, options::TopicReference},
types::{
IdentifiedQoS, MqttBinary, MqttString, MqttStringPair, PacketIdentifier, ReasonCode,
TopicName, VarByteInt,
Expand Down Expand Up @@ -255,8 +255,11 @@ pub struct Publish<'p, const MAX_SUBSCRIPTION_IDENTIFIERS: usize, const MAX_USER
/// the retain as published flag of the matching subscription.
pub retain: bool,

/// The exact topic of this publication.
pub topic: TopicName<'p>,
/// The topic of this publication. In the case of [`TopicReference::Mapping`], a new topic alias
/// mapping is created or an existing mapping is overwritten. In the case of
/// [`TopicReference::Alias`], an existing mapping is used and the mapped topic name is the referred
/// topic.
pub topic: TopicReference<'p>,

/// If present, indicates whether the payload is UTF-8. This value is set by the publisher and is
/// NOT verified by the client library.
Expand Down
Loading
Loading