pub struct ConnAck { /* private fields */ }Expand description
Represents an MQTT CONNACK packet.
The ConnAck packet is sent by the server in response to a Connect packet
from a client. It indicates whether the connection was accepted and provides
session status and optional properties.
§Example
use mqute_codec::protocol::v5::{ConnAck, ConnAckProperties, ReasonCode};
use std::time::Duration;
let properties = ConnAckProperties {
session_expiry_interval: Some(Duration::from_secs(3600)),
receive_maximum: Some(10),
..Default::default()
};
let connack = ConnAck::new(
ReasonCode::Success,
true,
Some(properties)
);
assert_eq!(connack.code(), ReasonCode::Success);
assert!(connack.session_present());Implementations§
Source§impl ConnAck
impl ConnAck
Sourcepub fn new(
code: ReasonCode,
session_present: bool,
properties: Option<ConnAckProperties>,
) -> Self
pub fn new( code: ReasonCode, session_present: bool, properties: Option<ConnAckProperties>, ) -> Self
Creates a new ConnAck packet.
Sourcepub fn code(&self) -> ReasonCode
pub fn code(&self) -> ReasonCode
Returns the reason code indicating the connection result.
Sourcepub fn session_present(&self) -> bool
pub fn session_present(&self) -> bool
Returns whether the server has a previous session for this client.
Sourcepub fn properties(&self) -> Option<ConnAckProperties>
pub fn properties(&self) -> Option<ConnAckProperties>
Returns the optional properties of the ConnAck packet.
Trait Implementations§
impl Eq for ConnAck
impl StructuralPartialEq for ConnAck
Auto Trait Implementations§
impl !Freeze for ConnAck
impl RefUnwindSafe for ConnAck
impl Send for ConnAck
impl Sync for ConnAck
impl Unpin for ConnAck
impl UnwindSafe for ConnAck
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