Struct Publish
pub struct Publish<'a> {
pub dup: bool,
pub qos: QoS,
pub retain: bool,
pub topic: Option<&'a Topic>,
pub packet_id: Option<PacketId>,
pub properties: &'a PublishProperties,
pub payload: &'a [u8],
}Expand description
PUBLISH packet carrying an application message.
Fields§
§dup: boolDuplicate delivery flag.
qos: QoSQuality of Service level.
retain: boolRetain flag.
topic: Option<&'a Topic>Topic name. None when resolved via topic alias.
packet_id: Option<PacketId>Packet identifier (present for QoS 1 and 2).
properties: &'a PublishPropertiesPUBLISH properties.
payload: &'a [u8]Application message payload.
Implementations§
§impl<'a> Publish<'a>
impl<'a> Publish<'a>
pub const fn flags_byte(&self) -> u8
pub const fn flags_byte(&self) -> u8
Returns the fixed-header flags byte for this PUBLISH.
pub const fn encoded_len(&self) -> usize
pub const fn encoded_len(&self) -> usize
Returns the encoded size of the variable header + payload in bytes.
pub const fn encode(&self, w: &mut Writer<'_>) -> Result<(), EncodeError>
pub const fn encode(&self, w: &mut Writer<'_>) -> Result<(), EncodeError>
Encodes the PUBLISH variable header + payload into the writer.
§Errors
Returns EncodeError::InsufficientSpace if the writer does not have
enough capacity.
pub const fn decode(flags: u8, r: &mut Reader<'a>) -> Result<Self, DecodeError>
pub const fn decode(flags: u8, r: &mut Reader<'a>) -> Result<Self, DecodeError>
Decodes a PUBLISH packet from the flags byte and reader.
§Errors
Returns DecodeError if the data is malformed, the QoS is invalid,
or properties contain disallowed IDs.
Trait Implementations§
impl<'a> Eq for Publish<'a>
impl<'a> StructuralPartialEq for Publish<'a>
Auto Trait Implementations§
impl<'a> Freeze for Publish<'a>
impl<'a> RefUnwindSafe for Publish<'a>
impl<'a> Send for Publish<'a>
impl<'a> Sync for Publish<'a>
impl<'a> Unpin for Publish<'a>
impl<'a> UnwindSafe for Publish<'a>
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