pub struct Disconnect { /* private fields */ }Expand description
Represents an MQTT v5 Disconnect packet.
The Disconnect packet is the final MQTT Control Packet sent from the Client
or the Server. It indicates the reason why the Network Connection is being closed
§Example
use mqute_codec::protocol::v5::{Disconnect, DisconnectProperties, ReasonCode};
let properties = DisconnectProperties {
reason_string: Some("Reason string".to_string()),
server_reference: Some("backup.example.com".to_string()),
..Default::default()
};
let disconnect = Disconnect::new(ReasonCode::Success, Some(properties.clone()));
assert_eq!(disconnect.properties(), Some(properties));Implementations§
Source§impl Disconnect
impl Disconnect
Sourcepub fn new(code: ReasonCode, properties: Option<DisconnectProperties>) -> Self
pub fn new(code: ReasonCode, properties: Option<DisconnectProperties>) -> Self
Creates a new Disconnect packet
Sourcepub fn code(&self) -> ReasonCode
pub fn code(&self) -> ReasonCode
Returns the reason code
Sourcepub fn properties(&self) -> Option<DisconnectProperties>
pub fn properties(&self) -> Option<DisconnectProperties>
Returns a copy of the properties (if any)
Trait Implementations§
Source§impl Clone for Disconnect
impl Clone for Disconnect
Source§fn clone(&self) -> Disconnect
fn clone(&self) -> Disconnect
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Disconnect
impl Debug for Disconnect
Source§impl Decode for Disconnect
impl Decode for Disconnect
Source§impl Encode for Disconnect
impl Encode for Disconnect
Source§impl PartialEq for Disconnect
impl PartialEq for Disconnect
impl Eq for Disconnect
impl StructuralPartialEq for Disconnect
Auto Trait Implementations§
impl Freeze for Disconnect
impl RefUnwindSafe for Disconnect
impl Send for Disconnect
impl Sync for Disconnect
impl Unpin for Disconnect
impl UnwindSafe for Disconnect
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