Message

Struct Message 

pub struct Message {
    pub topic: TopicBuf,
    pub payload: Vec<u8>,
    pub qos: QoS,
    pub retain: bool,
    pub content_type: Option<MqttString>,
    pub response_topic: Option<TopicBuf>,
    pub correlation_data: Option<MqttBytesBuf>,
    pub message_expiry: Option<u32>,
    pub payload_utf8: Option<bool>,
    pub subscription_ids: Vec<NonZeroVbi>,
    pub user_properties: Vec<(MqttString, MqttString)>,
}
Expand description

An incoming MQTT v5 message from the broker.

Contains the standard PUBLISH fields plus all applicable v5 properties extracted from the packet.

Fields§

§topic: TopicBuf

Topic the message was published to.

§payload: Vec<u8>

Message payload bytes.

§qos: QoS

Quality of Service level of the delivered message.

§retain: bool

Whether the message was retained by the broker.

§content_type: Option<MqttString>

MIME content type of the payload (property 0x03).

§response_topic: Option<TopicBuf>

Topic the receiver should use for responses (property 0x08).

§correlation_data: Option<MqttBytesBuf>

Correlation data for request/response flows (property 0x09).

§message_expiry: Option<u32>

Remaining lifetime of the message in seconds (property 0x02).

§payload_utf8: Option<bool>

Payload format: true = UTF-8, false = unspecified (property 0x01).

§subscription_ids: Vec<NonZeroVbi>

Subscription identifiers that caused this delivery (property 0x0B).

Multiple identifiers are possible when overlapping subscriptions match the same topic.

§user_properties: Vec<(MqttString, MqttString)>

User-defined key-value properties (property 0x26).

Implementations§

§

impl Message

pub(crate) fn from_publish( publish: &Publish<'_>, resolved_topic: Option<&TopicBuf>, ) -> Option<Self>

Build a Message from an incoming Publish packet, extracting all v5 properties.

If resolved_topic is Some, it overrides the topic in the packet (used when a topic alias was resolved).

Trait Implementations§

§

impl Clone for Message

§

fn clone(&self) -> Message

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
§

impl Debug for Message

§

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

Formats the value using the given formatter. Read more

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> 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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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, 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.