pub struct Publish { /* private fields */ }Expand description
Represents an MQTT Publish packet.
§Example
use mqute_codec::protocol::v4::Publish;
use mqute_codec::protocol::{QoS, Flags};
use bytes::Bytes;
let flags = Flags::new(QoS::AtLeastOnce);
let publish = Publish::new("topic", 1234, Bytes::from("message"), flags);
assert_eq!(publish.flags(), flags);
assert_eq!(publish.topic(), "topic");
assert_eq!(publish.packet_id(), Some(1234));
assert_eq!(publish.payload(), Bytes::from("message"));Implementations§
Source§impl Publish
impl Publish
Sourcepub fn new<T: Into<String>>(
topic: T,
packet_id: u16,
payload: Bytes,
flags: Flags,
) -> Self
pub fn new<T: Into<String>>( topic: T, packet_id: u16, payload: Bytes, flags: Flags, ) -> Self
Creates a new Publish packet.
§Panics
Panics if:
packet_idis zero for QoS > 0.- The topic name is invalid according to MQTT topic naming rules.
Sourcepub fn flags(&self) -> Flags
pub fn flags(&self) -> Flags
Returns the flags for the Publish packet.
The flags include QoS, retain, and duplicate delivery settings.
Trait Implementations§
impl Eq for Publish
impl Publish for Publish
impl StructuralPartialEq for Publish
Auto Trait Implementations§
impl !Freeze for Publish
impl RefUnwindSafe for Publish
impl Send for Publish
impl Sync for Publish
impl Unpin for Publish
impl UnwindSafe for Publish
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Encoded for Twhere
T: Encode,
impl<T> Encoded for Twhere
T: Encode,
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Calculates the total encoded length of the packet. Read more