pub struct Flags {
pub dup: bool,
pub qos: QoS,
pub retain: bool,
}Expand description
Packet header types and fixed header implementation Represents the control flags in an MQTT packet.
§Examples
use mqute_codec::protocol::QoS;
use mqute_codec::protocol::Flags;
// Create default flags
let default_flags = Flags::default();
assert_eq!(default_flags.dup, false);
assert_eq!(default_flags.qos, QoS::AtMostOnce);
assert_eq!(default_flags.retain, false);
// Create custom flags
let custom_flags = Flags::new(QoS::AtLeastOnce);
assert_eq!(custom_flags.qos, QoS::AtLeastOnce);Fields§
§dup: boolIndicates if the packet is a duplicate.
qos: QoSThe Quality of Service level (0, 1, or 2).
retain: boolIndicates if the message should be retained by the broker.
Implementations§
Source§impl Flags
impl Flags
Sourcepub fn new(qos: QoS) -> Self
pub fn new(qos: QoS) -> Self
Creates new Flags with the specified QoS level.
§Examples
use mqute_codec::protocol::QoS;
use mqute_codec::protocol::Flags;
let flags = Flags::new(QoS::ExactlyOnce);
assert_eq!(flags.qos, QoS::ExactlyOnce);Sourcepub fn is_default(&self) -> bool
pub fn is_default(&self) -> bool
Checks if the flags are set to their default values.
§Examples
use mqute_codec::protocol::Flags;
let flags = Flags::default();
assert!(flags.is_default());Trait Implementations§
impl Copy for Flags
impl Eq for Flags
impl StructuralPartialEq for Flags
Auto Trait Implementations§
impl Freeze for Flags
impl RefUnwindSafe for Flags
impl Send for Flags
impl Sync for Flags
impl Unpin for Flags
impl UnwindSafe for Flags
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