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