Rust

connection

Module

Per-connection state: the session CONNECT negotiated, and the delivery state of QoS 1 messages in flight.

Contents

use utopia_mqtt::Ack;
Rust
pub struct Ack

A delivery a PUBACK acknowledged.

use utopia_mqtt::Connection;
Rust
pub struct Connection

One client connection, by the transport's connection id: its session State, and its outbound deliveries. A broker shares it (cheap to clone behind an Arc); every method takes &self.

Delivery draws packet ids and tracks each QoS 1 message in flight until its PUBACK, which advances a per-topic cursor: the highest sequence acknowledged without a gap below it.

Rust
use utopia_mqtt::Connection;

let connection = Connection::new(1, None);
connection.track(1, b"topic", 5);
connection.track(2, b"topic", 6);
connection.track(3, b"topic", 7);
assert_eq!(connection.acknowledge(1).unwrap().cursor, 5);
assert_eq!(connection.acknowledge(3).unwrap().cursor, 5); // 6 is still out
assert_eq!(connection.acknowledge(2).unwrap().cursor, 7);
assert_eq!(connection.acknowledge(2), None);
Also implements Debug.
use utopia_mqtt::State;
Rust
pub struct State

What the broker knows about a connection's session. Read and change it through Connection::state.

Also implements Default, Debug.