PacketKind

Trait PacketKind 

Source
pub trait PacketKind {
Show 17 associated constants and 0 method const IS_CONNECT: bool = false; const IS_CONNACK: bool = false; const IS_PUBLISH: bool = false; const IS_PUBACK: bool = false; const IS_PUBREC: bool = false; const IS_PUBREL: bool = false; const IS_PUBCOMP: bool = false; const IS_SUBSCRIBE: bool = false; const IS_SUBACK: bool = false; const IS_UNSUBSCRIBE: bool = false; const IS_UNSUBACK: bool = false; const IS_PINGREQ: bool = false; const IS_PINGRESP: bool = false; const IS_DISCONNECT: bool = false; const IS_AUTH: bool = false; const IS_V3_1_1: bool = false; const IS_V5_0: bool = false;
}
Expand description

Trait for compile-time packet classification and type introspection

PacketKind provides a way to classify MQTT packet types at compile time using constant boolean flags. This enables efficient type-based dispatch and filtering without runtime overhead. Each MQTT packet type implements this trait with appropriate flags set to true.

The trait includes flags for:

  • Packet types: CONNECT, CONNACK, PUBLISH, PUBACK, PUBREC, PUBREL, PUBCOMP, SUBSCRIBE, SUBACK, UNSUBSCRIBE, UNSUBACK, PINGREQ, PINGRESP, DISCONNECT, AUTH
  • Protocol versions: V3_1_1, V5_0

§Examples

use mqtt_protocol_core::mqtt::packet::PacketKind;
use mqtt_protocol_core::mqtt::packet::v5_0::Connect;

// Check packet type at compile time
if Connect::IS_CONNECT {
    println!("This is a CONNECT packet");
}

// Check protocol version
if Connect::IS_V5_0 {
    println!("This is a v5.0 packet");
}

Provided Associated Constants§

Source

const IS_CONNECT: bool = false

true if this is a CONNECT packet

Source

const IS_CONNACK: bool = false

true if this is a CONNACK packet

Source

const IS_PUBLISH: bool = false

true if this is a PUBLISH packet

Source

const IS_PUBACK: bool = false

true if this is a PUBACK packet

Source

const IS_PUBREC: bool = false

true if this is a PUBREC packet

Source

const IS_PUBREL: bool = false

true if this is a PUBREL packet

Source

const IS_PUBCOMP: bool = false

true if this is a PUBCOMP packet

Source

const IS_SUBSCRIBE: bool = false

true if this is a SUBSCRIBE packet

Source

const IS_SUBACK: bool = false

true if this is a SUBACK packet

Source

const IS_UNSUBSCRIBE: bool = false

true if this is an UNSUBSCRIBE packet

Source

const IS_UNSUBACK: bool = false

true if this is an UNSUBACK packet

Source

const IS_PINGREQ: bool = false

true if this is a PINGREQ packet

Source

const IS_PINGRESP: bool = false

true if this is a PINGRESP packet

Source

const IS_DISCONNECT: bool = false

true if this is a DISCONNECT packet

Source

const IS_AUTH: bool = false

true if this is an AUTH packet (v5.0 only)

Source

const IS_V3_1_1: bool = false

true if this is an MQTT v3.1.1 packet

Source

const IS_V5_0: bool = false

true if this is an MQTT v5.0 packet

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T: PacketKind> PacketKind for &T

PacketKind implementation for references to packet types

This implementation forwards all flags from the referenced type, allowing packet references to be used with the same type checking.

Source§

const IS_CONNECT: bool = T::IS_CONNECT

Source§

const IS_CONNACK: bool = T::IS_CONNACK

Source§

const IS_PUBLISH: bool = T::IS_PUBLISH

Source§

const IS_PUBACK: bool = T::IS_PUBACK

Source§

const IS_PUBREC: bool = T::IS_PUBREC

Source§

const IS_PUBREL: bool = T::IS_PUBREL

Source§

const IS_PUBCOMP: bool = T::IS_PUBCOMP

Source§

const IS_SUBSCRIBE: bool = T::IS_SUBSCRIBE

Source§

const IS_SUBACK: bool = T::IS_SUBACK

Source§

const IS_UNSUBSCRIBE: bool = T::IS_UNSUBSCRIBE

Source§

const IS_UNSUBACK: bool = T::IS_UNSUBACK

Source§

const IS_PINGREQ: bool = T::IS_PINGREQ

Source§

const IS_PINGRESP: bool = T::IS_PINGRESP

Source§

const IS_DISCONNECT: bool = T::IS_DISCONNECT

Source§

const IS_AUTH: bool = T::IS_AUTH

Source§

const IS_V3_1_1: bool = T::IS_V3_1_1

Source§

const IS_V5_0: bool = T::IS_V5_0

Implementors§

Source§

impl PacketKind for mqtt_protocol_core::mqtt::packet::v3_1_1::Connack

PacketKind implementation for v3.1.1 CONNACK packet

Source§

const IS_CONNACK: bool = true

Source§

const IS_V3_1_1: bool = true

Source§

impl PacketKind for mqtt_protocol_core::mqtt::packet::v3_1_1::Connect

PacketKind implementation for v3.1.1 CONNECT packet

Source§

const IS_CONNECT: bool = true

Source§

const IS_V3_1_1: bool = true

Source§

impl PacketKind for mqtt_protocol_core::mqtt::packet::v3_1_1::Disconnect

PacketKind implementation for v3.1.1 DISCONNECT packet

Source§

impl PacketKind for mqtt_protocol_core::mqtt::packet::v3_1_1::Pingreq

PacketKind implementation for v3.1.1 PINGREQ packet

Source§

const IS_PINGREQ: bool = true

Source§

const IS_V3_1_1: bool = true

Source§

impl PacketKind for mqtt_protocol_core::mqtt::packet::v3_1_1::Pingresp

PacketKind implementation for v3.1.1 PINGRESP packet

Source§

const IS_PINGRESP: bool = true

Source§

const IS_V3_1_1: bool = true

Source§

impl PacketKind for Auth

PacketKind implementation for v5.0 AUTH packet (v5.0 exclusive)

Source§

const IS_AUTH: bool = true

Source§

const IS_V5_0: bool = true

Source§

impl PacketKind for mqtt_protocol_core::mqtt::packet::v5_0::Connack

PacketKind implementation for v5.0 CONNACK packet

Source§

const IS_CONNACK: bool = true

Source§

const IS_V5_0: bool = true

Source§

impl PacketKind for mqtt_protocol_core::mqtt::packet::v5_0::Connect

PacketKind implementation for v5.0 CONNECT packet

Source§

const IS_CONNECT: bool = true

Source§

const IS_V5_0: bool = true

Source§

impl PacketKind for mqtt_protocol_core::mqtt::packet::v5_0::Disconnect

Source§

const IS_DISCONNECT: bool = true

Source§

const IS_V5_0: bool = true

Source§

impl PacketKind for mqtt_protocol_core::mqtt::packet::v5_0::Pingreq

PacketKind implementation for v5.0 PINGREQ packet

Source§

const IS_PINGREQ: bool = true

Source§

const IS_V5_0: bool = true

Source§

impl PacketKind for mqtt_protocol_core::mqtt::packet::v5_0::Pingresp

Source§

const IS_PINGRESP: bool = true

Source§

const IS_V5_0: bool = true

Source§

impl<PacketIdType> PacketKind for GenericPacket<PacketIdType>
where PacketIdType: IsPacketId + Serialize,

PacketKind implementation for GenericPacket enum

For enum types, all flags are false at compile time since the actual packet type is determined at runtime. This implementation provides a fallback for generic packet handling where compile-time type information is not available.

Source§

impl<PacketIdType> PacketKind for mqtt_protocol_core::mqtt::packet::v3_1_1::GenericPuback<PacketIdType>
where PacketIdType: IsPacketId,

Source§

const IS_PUBACK: bool = true

Source§

const IS_V3_1_1: bool = true

Source§

impl<PacketIdType> PacketKind for mqtt_protocol_core::mqtt::packet::v3_1_1::GenericPubcomp<PacketIdType>
where PacketIdType: IsPacketId,

Source§

const IS_PUBCOMP: bool = true

Source§

const IS_V3_1_1: bool = true

Source§

impl<PacketIdType> PacketKind for mqtt_protocol_core::mqtt::packet::v3_1_1::GenericPublish<PacketIdType>
where PacketIdType: IsPacketId + 'static,

PacketKind implementation for generic v3.1.1 PUBLISH packet

Source§

const IS_PUBLISH: bool = true

Source§

const IS_V3_1_1: bool = true

Source§

impl<PacketIdType> PacketKind for mqtt_protocol_core::mqtt::packet::v3_1_1::GenericPubrec<PacketIdType>
where PacketIdType: IsPacketId,

Source§

const IS_PUBREC: bool = true

Source§

const IS_V3_1_1: bool = true

Source§

impl<PacketIdType> PacketKind for mqtt_protocol_core::mqtt::packet::v3_1_1::GenericPubrel<PacketIdType>
where PacketIdType: IsPacketId,

Source§

const IS_PUBREL: bool = true

Source§

const IS_V3_1_1: bool = true

Source§

impl<PacketIdType> PacketKind for mqtt_protocol_core::mqtt::packet::v3_1_1::GenericSuback<PacketIdType>
where PacketIdType: IsPacketId,

Source§

const IS_SUBACK: bool = true

Source§

const IS_V3_1_1: bool = true

Source§

impl<PacketIdType> PacketKind for mqtt_protocol_core::mqtt::packet::v3_1_1::GenericSubscribe<PacketIdType>
where PacketIdType: IsPacketId,

Source§

const IS_SUBSCRIBE: bool = true

Source§

const IS_V3_1_1: bool = true

Source§

impl<PacketIdType> PacketKind for mqtt_protocol_core::mqtt::packet::v3_1_1::GenericUnsuback<PacketIdType>
where PacketIdType: IsPacketId,

Source§

const IS_UNSUBACK: bool = true

Source§

const IS_V3_1_1: bool = true

Source§

impl<PacketIdType> PacketKind for mqtt_protocol_core::mqtt::packet::v3_1_1::GenericUnsubscribe<PacketIdType>
where PacketIdType: IsPacketId,

Source§

impl<PacketIdType> PacketKind for mqtt_protocol_core::mqtt::packet::v5_0::GenericPuback<PacketIdType>
where PacketIdType: IsPacketId,

Source§

const IS_PUBACK: bool = true

Source§

const IS_V5_0: bool = true

Source§

impl<PacketIdType> PacketKind for mqtt_protocol_core::mqtt::packet::v5_0::GenericPubcomp<PacketIdType>
where PacketIdType: IsPacketId,

Source§

const IS_PUBCOMP: bool = true

Source§

const IS_V5_0: bool = true

Source§

impl<PacketIdType> PacketKind for mqtt_protocol_core::mqtt::packet::v5_0::GenericPublish<PacketIdType>
where PacketIdType: IsPacketId,

Source§

const IS_PUBLISH: bool = true

Source§

const IS_V5_0: bool = true

Source§

impl<PacketIdType> PacketKind for mqtt_protocol_core::mqtt::packet::v5_0::GenericPubrec<PacketIdType>
where PacketIdType: IsPacketId,

Source§

const IS_PUBREC: bool = true

Source§

const IS_V5_0: bool = true

Source§

impl<PacketIdType> PacketKind for mqtt_protocol_core::mqtt::packet::v5_0::GenericPubrel<PacketIdType>
where PacketIdType: IsPacketId,

Source§

const IS_PUBREL: bool = true

Source§

const IS_V5_0: bool = true

Source§

impl<PacketIdType> PacketKind for mqtt_protocol_core::mqtt::packet::v5_0::GenericSuback<PacketIdType>
where PacketIdType: IsPacketId,

Source§

const IS_SUBACK: bool = true

Source§

const IS_V5_0: bool = true

Source§

impl<PacketIdType> PacketKind for mqtt_protocol_core::mqtt::packet::v5_0::GenericSubscribe<PacketIdType>
where PacketIdType: IsPacketId,

Source§

const IS_SUBSCRIBE: bool = true

Source§

const IS_V5_0: bool = true

Source§

impl<PacketIdType> PacketKind for mqtt_protocol_core::mqtt::packet::v5_0::GenericUnsuback<PacketIdType>
where PacketIdType: IsPacketId,

Source§

const IS_UNSUBACK: bool = true

Source§

const IS_V5_0: bool = true

Source§

impl<PacketIdType> PacketKind for mqtt_protocol_core::mqtt::packet::v5_0::GenericUnsubscribe<PacketIdType>
where PacketIdType: IsPacketId,

Source§

const IS_UNSUBSCRIBE: bool = true

Source§

const IS_V5_0: bool = true