pub struct Message { /* private fields */ }
Expand description
A Message
represents all the information passed in an MQTT PUBLISH
packet.
This is the primary data transfer mechanism.
Implementations§
Source§impl Message
impl Message
Sourcepub fn new<S, V, Q>(topic: S, payload: V, qos: Q) -> Self
pub fn new<S, V, Q>(topic: S, payload: V, qos: Q) -> Self
Creates a new message.
§Arguments
topic
The topic on which the message is published.payload
The binary payload of the messageqos
The quality of service for message delivery (0, 1, or 2)
Sourcepub fn new_retained<S, V, Q>(topic: S, payload: V, qos: Q) -> Self
pub fn new_retained<S, V, Q>(topic: S, payload: V, qos: Q) -> Self
Creates a new message that will be retained by the broker. This creates a message with the ‘retained’ flag set.
§Arguments
topic
The topic on which the message is published.payload
The binary payload of the messageqos
The quality of service for message delivery (0, 1, or 2)
Sourcepub fn payload(&self) -> &[u8] ⓘ
pub fn payload(&self) -> &[u8] ⓘ
Gets the payload of the message. This returns the payload as a slice.
Sourcepub fn payload_str(&self) -> Cow<'_, str>
pub fn payload_str(&self) -> Cow<'_, str>
Gets the payload of the message as a string.
This utilizes the “lossy” style of conversion from the std library.
If the contents of the CStr are valid UTF-8 data, this function will
return a Cow::Borrowed(&str)
with the the corresponding &str
slice.
Otherwise, it will replace any invalid UTF-8 sequences with U+FFFD
REPLACEMENT CHARACTER and return a Cow::Owned(String)
with the result.
Sourcepub fn properties(&self) -> &Properties
pub fn properties(&self) -> &Properties
Gets the properties in the message
Trait Implementations§
Source§impl From<DeliveryToken> for Message
impl From<DeliveryToken> for Message
Source§fn from(v: DeliveryToken) -> Message
fn from(v: DeliveryToken) -> Message
Converts to this type from the input type.
Source§impl From<Message> for WillOptions
impl From<Message> for WillOptions
impl Send for Message
impl Sync for Message
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more