pub struct Connect { /* private fields */ }Expand description
Represents an MQTT Connect packet
This packet initiates a connection between client and broker and contains all necessary parameters for the session.
§Example
use std::time::Duration;
use bytes::Bytes;
use mqute_codec::protocol::{v5, Credentials, Protocol, QoS};
let connect = v5::Connect::new(
"client",
Some(Credentials::full("user", "pass")),
Some(v5::Will::new(
None,
"device/status",
Bytes::from("disconnected"),
QoS::ExactlyOnce,
true
)),
Duration::from_secs(30),
true
);
assert!(connect.will().is_some());
assert_eq!(connect.protocol(), Protocol::V5);
assert_eq!(connect.client_id(), "client");Implementations§
Source§impl Connect
impl Connect
Sourcepub fn new<S: Into<String>>(
client_id: S,
credentials: Option<Credentials>,
will: Option<Will>,
keep_alive: Duration,
clean_session: bool,
) -> Self
pub fn new<S: Into<String>>( client_id: S, credentials: Option<Credentials>, will: Option<Will>, keep_alive: Duration, clean_session: bool, ) -> Self
Creates a new Connect packet with basic parameters
§Panics
Panics if the value of the “keep alive” parameter exceeds 65535
Sourcepub fn keep_alive(&self) -> Duration
pub fn keep_alive(&self) -> Duration
Returns the keep alive time in seconds
Sourcepub fn clean_session(&self) -> bool
pub fn clean_session(&self) -> bool
Returns whether this is a clean session
Sourcepub fn credentials(&self) -> Option<Credentials>
pub fn credentials(&self) -> Option<Credentials>
Returns the authentication credentials if present
Trait Implementations§
impl Eq for Connect
impl StructuralPartialEq for Connect
Auto Trait Implementations§
impl !Freeze for Connect
impl RefUnwindSafe for Connect
impl Send for Connect
impl Sync for Connect
impl Unpin for Connect
impl UnwindSafe for Connect
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