pub struct SubAck { /* private fields */ }Expand description
Represents an MQTT v5 SubAck packet
The SubAck packet is sent by the server to acknowledge receipt and processing
of a Subscribe packet. It contains:
- Packet Identifier matching the
Subscribepacket - List of return codes indicating granted QoS levels or errors
- Optional properties (v5 only)
§Example
use mqute_codec::protocol::Codes;
use mqute_codec::protocol::v5::{SubAck, ReasonCode};
// Successful subscription with different QoS levels
let suback = SubAck::new(
1234,
None,
vec![
ReasonCode::GrantedQos0,
ReasonCode::GrantedQos2,
ReasonCode::GrantedQos1
],
);
assert_eq!(suback.packet_id(), 1234u16);
let codes = Codes::new(vec![
ReasonCode::GrantedQos0,
ReasonCode::GrantedQos2,
ReasonCode::GrantedQos1
]);
assert_eq!(suback.codes(), codes);Implementations§
Source§impl SubAck
impl SubAck
Sourcepub fn new<T>(
packet_id: u16,
properties: Option<SubAckProperties>,
codes: T,
) -> Selfwhere
T: IntoIterator<Item = ReasonCode>,
pub fn new<T>(
packet_id: u16,
properties: Option<SubAckProperties>,
codes: T,
) -> Selfwhere
T: IntoIterator<Item = ReasonCode>,
Creates a new SubAck packet
§Panics
- If no reason codes are provided
- If any reason code is invalid for
SubAck
Sourcepub fn codes(&self) -> Codes<ReasonCode>
pub fn codes(&self) -> Codes<ReasonCode>
Returns the list of reason codes
Sourcepub fn properties(&self) -> Option<SubAckProperties>
pub fn properties(&self) -> Option<SubAckProperties>
Returns a copy of the properties (if any)
Trait Implementations§
impl Eq for SubAck
impl StructuralPartialEq for SubAck
Auto Trait Implementations§
impl Freeze for SubAck
impl RefUnwindSafe for SubAck
impl Send for SubAck
impl Sync for SubAck
impl Unpin for SubAck
impl UnwindSafe for SubAck
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