Enum SessionOp
pub enum SessionOp<'a> {
StoreOutbox {
packet_id: PacketId,
qos: QoS,
topic: &'a Topic,
payload: &'a [u8],
retain: bool,
properties: &'a PublishProperties,
},
RemoveOutbox {
packet_id: PacketId,
},
MarkSent {
packet_id: PacketId,
},
StorePubrelPending {
packet_id: PacketId,
},
RemovePubrelPending {
packet_id: PacketId,
},
StoreIncomingQos2 {
packet_id: PacketId,
},
RemoveIncomingQos2 {
packet_id: PacketId,
},
Clear,
StoreFilter {
filter: &'a TopicFilter,
state: FilterState,
},
RemoveFilter {
filter: &'a TopicFilter,
},
}Expand description
A single mutation to session state, in a form that can be serialized and replayed.
Passed to super::SessionState::apply to mutate the session. A
persistence backend can also match on it to map each operation onto its own
representation (e.g. SQL statements), the same way
Property is matched.
The store_* / remove_* constructors build the variants and are handy
at call sites; the wire op code is an encoding detail derived from the
variant.
Variants§
StoreOutbox
Store (or replace) an outgoing publish in the outbox.
Fields
properties: &'a PublishPropertiesv5 publish properties.
RemoveOutbox
Remove an outgoing publish from the outbox.
MarkSent
Mark a stored outgoing publish as having been written to the wire, so a post-restart retransmit carries DUP=1 as required by MQTT §3.3.1.1 [MQTT-3.3.1-1].
StorePubrelPending
Store a QoS 2 entry directly in the awaiting-PUBCOMP (pubrel-pending)
state.
RemovePubrelPending
Remove a QoS 2 entry from the pubrel-pending set.
StoreIncomingQos2
Store an incoming QoS 2 publish in the awaiting-PUBREL state.
RemoveIncomingQos2
Remove an incoming QoS 2 publish.
Clear
Clear all in-flight state. Confirmed subscriptions are preserved.
StoreFilter
Store (or replace) a filter entry verbatim. Persists the per-filter subscription model: a confirmed subscription, an in-flight SUBSCRIBE, or an in-flight UNSUBSCRIBE. The state carries the subscription options and identifier where they apply.
Fields
filter: &'a TopicFilterTopic filter.
state: FilterStateLifecycle state, including options and subscription id where they apply.
RemoveFilter
Remove a filter entry.
Fields
filter: &'a TopicFilterTopic filter to remove.
Implementations§
§impl<'a> SessionOp<'a>
impl<'a> SessionOp<'a>
pub const fn store_outbox(packet_id: PacketId, entry: &OutboxEntry<'a>) -> Self
pub const fn store_outbox(packet_id: PacketId, entry: &OutboxEntry<'a>) -> Self
Creates an operation to store an outgoing publish from an
OutboxEntry, preserving its QoS.
pub const fn remove_outbox(packet_id: PacketId) -> Self
pub const fn remove_outbox(packet_id: PacketId) -> Self
Creates an operation to remove an outgoing publish from the outbox.
Removal is keyed by packet id alone; the entry’s QoS is irrelevant.
pub const fn store_qos2_pubcomp(packet_id: PacketId) -> Self
pub const fn store_qos2_pubcomp(packet_id: PacketId) -> Self
Creates an operation to store a QoS 2 entry directly in the
awaiting-PUBCOMP state.
pub const fn remove_pubrel(packet_id: PacketId) -> Self
pub const fn remove_pubrel(packet_id: PacketId) -> Self
Creates an operation to remove a QoS 2 entry from the
awaiting-PUBCOMP phase (pubrel-pending set).
pub const fn store_incoming_qos2(packet_id: PacketId) -> Self
pub const fn store_incoming_qos2(packet_id: PacketId) -> Self
Creates an operation to store an incoming QoS 2 publish in the
“awaiting PUBREC” phase.
pub const fn remove_incoming_qos2(packet_id: PacketId) -> Self
pub const fn remove_incoming_qos2(packet_id: PacketId) -> Self
Creates an operation to remove an incoming QoS 2 publish.
pub const fn clear() -> Self
pub const fn clear() -> Self
Creates an operation to clear all in-flight session state.
pub const fn store_filter(filter: &'a TopicFilter, state: FilterState) -> Self
pub const fn store_filter(filter: &'a TopicFilter, state: FilterState) -> Self
Creates an operation to store (or replace) a filter entry verbatim.
pub const fn remove_filter(filter: &'a TopicFilter) -> Self
pub const fn remove_filter(filter: &'a TopicFilter) -> Self
Creates an operation to remove a filter entry.
pub const fn mark_sent(packet_id: PacketId) -> Self
pub const fn mark_sent(packet_id: PacketId) -> Self
Creates an operation that marks a pending QoS 1 or QoS 2 publish as
having been written to the wire at least once.
Journaling this ensures that, after a process restart, retransmissions carry DUP=1 as required by MQTT §3.3.1.1 [MQTT-3.3.1-1].
pub const fn encoded_len(&self) -> usize
pub const fn encoded_len(&self) -> usize
Returns the total length of the encoded operation.
pub fn encode_to_vec(&self, buf: &mut Vec<u8>)
Available on crate feature alloc only.
pub fn encode_to_vec(&self, buf: &mut Vec<u8>)
alloc only.Encodes this operation into the provided buffer.
pub const fn encode(&self, w: &mut Writer<'_>) -> Result<(), EncodeError>
pub const fn encode(&self, w: &mut Writer<'_>) -> Result<(), EncodeError>
Encodes this operation into the provided writer.
§Errors
Returns EncodeError::InsufficientSpace if the writer does not
have enough remaining capacity.
pub fn decode(r: &mut Reader<'a>) -> Result<Self, OpDecodeError>
pub fn decode(r: &mut Reader<'a>) -> Result<Self, OpDecodeError>
Decodes an operation from the provided reader.
§Errors
Returns OpDecodeError if the reader contains invalid data.