pub struct MqttBuilder { /* private fields */ }Expand description
Builder for MQTT packets.
By default, builds a PINGREQ message (\xC0\x00).
Implementations§
Source§impl MqttBuilder
impl MqttBuilder
Sourcepub fn unsubscribe(self) -> Self
pub fn unsubscribe(self) -> Self
Set message type to UNSUBSCRIBE (10).
Sourcepub fn disconnect(self) -> Self
pub fn disconnect(self) -> Self
Set message type to DISCONNECT (14).
Sourcepub fn proto_name<T: Into<Vec<u8>>>(self, name: T) -> Self
pub fn proto_name<T: Into<Vec<u8>>>(self, name: T) -> Self
Set the protocol name (default: “MQTT”).
Sourcepub fn proto_level(self, level: u8) -> Self
pub fn proto_level(self, level: u8) -> Self
Set the protocol level (default: 4 for MQTT 3.1.1).
Sourcepub fn clean_session(self, val: bool) -> Self
pub fn clean_session(self, val: bool) -> Self
Set the clean session flag.
Sourcepub fn will(self, topic: &[u8], msg: &[u8], qos: u8, retain: bool) -> Self
pub fn will(self, topic: &[u8], msg: &[u8], qos: u8, retain: bool) -> Self
Set the will flag and optionally will topic/message.
Sourcepub fn keep_alive(self, secs: u16) -> Self
pub fn keep_alive(self, secs: u16) -> Self
Set the keep alive value (seconds).
Sourcepub fn add_topic(self, filter: &[u8], qos: u8) -> Self
pub fn add_topic(self, filter: &[u8], qos: u8) -> Self
Add a topic filter with requested QoS for SUBSCRIBE.
Sourcepub fn sess_present(self, val: u8) -> Self
pub fn sess_present(self, val: u8) -> Self
Set the session present flag for CONNACK.
Sourcepub fn remaining_size(&self) -> usize
pub fn remaining_size(&self) -> usize
Compute the size of the variable header + payload (the remaining length).
Sourcepub fn header_size(&self) -> usize
pub fn header_size(&self) -> usize
Compute the total header size (fixed header bytes only).
Sourcepub fn packet_size(&self) -> usize
pub fn packet_size(&self) -> usize
Compute the total packet size.
Trait Implementations§
Source§impl Clone for MqttBuilder
impl Clone for MqttBuilder
Source§fn clone(&self) -> MqttBuilder
fn clone(&self) -> MqttBuilder
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 MqttBuilder
impl Debug for MqttBuilder
Source§impl Default for MqttBuilder
impl Default for MqttBuilder
Source§impl IntoLayerStackEntry for MqttBuilder
impl IntoLayerStackEntry for MqttBuilder
fn into_layer_stack_entry(self) -> LayerStackEntry
Auto Trait Implementations§
impl Freeze for MqttBuilder
impl RefUnwindSafe for MqttBuilder
impl Send for MqttBuilder
impl Sync for MqttBuilder
impl Unpin for MqttBuilder
impl UnsafeUnpin for MqttBuilder
impl UnwindSafe for MqttBuilder
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more