Enum FixedHeader

Source
#[repr(u8)]
pub enum FixedHeader {
Show 15 variants Connect = 16, Connack = 32, Publish = 48, Puback = 64, Pubrec = 80, Pubrel = 98, Pubcomp = 112, Subscribe = 130, Suback = 144, Unsubscribe = 162, Unsuback = 176, Pingreq = 192, Pingresp = 208, Disconnect = 224, Auth = 240,
}
Expand description

MQTT Fixed Header first byte enumeration

Represents the complete first byte of the MQTT Fixed Header, which includes both the packet type (bits 7-4) and packet-specific flags (bits 3-0). Each variant contains the full byte value with appropriate flags/reserved bits set.

§Packet-Specific Flags

  • PUBLISH: Contains DUP, QoS, and RETAIN flags (bits 3-0)
  • PUBREL, SUBSCRIBE, UNSUBSCRIBE: Have reserved bits set as required by spec
  • Other packets: Flags/reserved bits are typically zero

§Examples

use mqtt_protocol_core::mqtt::packet::FixedHeader;

let header = FixedHeader::Connect;
assert_eq!(header.as_u8(), 0x10);
assert_eq!(header.packet_type(), PacketType::Connect);

Variants§

§

Connect = 16

CONNECT packet header (0x10)

§

Connack = 32

CONNACK packet header (0x20)

§

Publish = 48

PUBLISH packet header (0x30) - flags for DUP, QoS, RETAIN in lower bits

§

Puback = 64

PUBACK packet header (0x40)

§

Pubrec = 80

PUBREC packet header (0x50)

§

Pubrel = 98

PUBREL packet header (0x62) - reserved bits set as required

§

Pubcomp = 112

PUBCOMP packet header (0x70)

§

Subscribe = 130

SUBSCRIBE packet header (0x82) - reserved bits set as required

§

Suback = 144

SUBACK packet header (0x90)

§

Unsubscribe = 162

UNSUBSCRIBE packet header (0xa2) - reserved bits set as required

§

Unsuback = 176

UNSUBACK packet header (0xb0)

§

Pingreq = 192

PINGREQ packet header (0xc0)

§

Pingresp = 208

PINGRESP packet header (0xd0)

§

Disconnect = 224

DISCONNECT packet header (0xe0)

§

Auth = 240

AUTH packet header (0xf0) - MQTT v5.0 only

Implementations§

Source§

impl FixedHeader

Source

pub fn as_u8(self) -> u8

Convert the fixed header to its byte value

Returns the complete first byte of the MQTT Fixed Header, including both packet type and flags/reserved bits.

§Returns

The fixed header byte value

Source

pub fn packet_type(self) -> PacketType

Extract the packet type from the fixed header

Extracts the packet type from bits 7-4 of the fixed header byte, discarding the flags/reserved bits in the lower 4 bits.

§Returns

The PacketType extracted from the header, or PacketType::Connect as fallback

Source

pub fn as_str(&self) -> &'static str

Convert the fixed header to its string representation

Returns the string representation of the underlying packet type. This is equivalent to calling self.packet_type().as_str().

§Returns

A static string slice with the packet type name

Trait Implementations§

Source§

impl Clone for FixedHeader

Source§

fn clone(&self) -> FixedHeader

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FixedHeader

Debug FixedHeader using Display implementation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for FixedHeader

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for FixedHeader

Display FixedHeader as JSON string

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for FixedHeader

Source§

fn eq(&self, other: &FixedHeader) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for FixedHeader

Serialize FixedHeader as a string

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<u8> for FixedHeader

Source§

type Error = TryFromPrimitiveError<FixedHeader>

The type returned in the event of a conversion error.
Source§

fn try_from(number: u8) -> Result<Self, TryFromPrimitiveError<Self>>

Performs the conversion.
Source§

impl TryFromPrimitive for FixedHeader

Source§

impl Copy for FixedHeader

Source§

impl Eq for FixedHeader

Source§

impl StructuralPartialEq for FixedHeader

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsConcrete<T> for T

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoConcreteOwned<T> for T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,