pub struct MqttSnBuilder { /* private fields */ }Expand description
Builder for MQTT-SN packets.
The builder produces a complete MQTT-SN message with the appropriate length prefix (1-byte or 3-byte extended).
Implementations§
Source§impl MqttSnBuilder
impl MqttSnBuilder
Sourcepub fn willtopicreq() -> Self
pub fn willtopicreq() -> Self
WILLTOPICREQ message builder.
Sourcepub fn willmsgreq() -> Self
pub fn willmsgreq() -> Self
WILLMSGREQ message builder.
Sourcepub fn unsubscribe() -> Self
pub fn unsubscribe() -> Self
UNSUBSCRIBE message builder.
Sourcepub fn disconnect() -> Self
pub fn disconnect() -> Self
DISCONNECT message builder.
Sourcepub fn willtopicupd() -> Self
pub fn willtopicupd() -> Self
WILLTOPICUPD message builder.
Sourcepub fn willtopicresp() -> Self
pub fn willtopicresp() -> Self
WILLTOPICRESP message builder.
Sourcepub fn willmsgupd() -> Self
pub fn willmsgupd() -> Self
WILLMSGUPD message builder.
Sourcepub fn willmsgresp() -> Self
pub fn willmsgresp() -> Self
WILLMSGRESP message builder.
Sourcepub fn client_id_str(self, v: &str) -> Self
pub fn client_id_str(self, v: &str) -> Self
Set the Client ID from a string.
Sourcepub fn return_code(self, v: u8) -> Self
pub fn return_code(self, v: u8) -> Self
Set the Return Code.
Sourcepub fn topic_name(self, v: &[u8]) -> Self
pub fn topic_name(self, v: &[u8]) -> Self
Set the Topic Name.
Sourcepub fn topic_name_str(self, v: &str) -> Self
pub fn topic_name_str(self, v: &str) -> Self
Set the Topic Name from a string.
Sourcepub fn will_topic_bytes(self, v: &[u8]) -> Self
pub fn will_topic_bytes(self, v: &[u8]) -> Self
Set the Will Topic.
Sourcepub fn will_topic_str(self, v: &str) -> Self
pub fn will_topic_str(self, v: &str) -> Self
Set the Will Topic from a string.
Sourcepub fn will_msg_bytes(self, v: &[u8]) -> Self
pub fn will_msg_bytes(self, v: &[u8]) -> Self
Set the Will Message.
Sourcepub fn build(&self) -> Vec<u8> ⓘ
pub fn build(&self) -> Vec<u8> ⓘ
Serialize the MQTT-SN message into bytes.
Automatically selects 1-byte or 3-byte extended length encoding:
- If total length < 256 and >= 2: single byte
- If total length >= 256: 0x01 prefix + 2-byte BE u16
Sourcepub fn build_into(&self, buf: &mut Vec<u8>) -> usize
pub fn build_into(&self, buf: &mut Vec<u8>) -> usize
Serialize into an existing buffer. Returns the number of bytes written.
Trait Implementations§
Source§impl Clone for MqttSnBuilder
impl Clone for MqttSnBuilder
Source§fn clone(&self) -> MqttSnBuilder
fn clone(&self) -> MqttSnBuilder
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 MqttSnBuilder
impl Debug for MqttSnBuilder
Source§impl Default for MqttSnBuilder
impl Default for MqttSnBuilder
Source§impl IntoLayerStackEntry for MqttSnBuilder
impl IntoLayerStackEntry for MqttSnBuilder
fn into_layer_stack_entry(self) -> LayerStackEntry
Auto Trait Implementations§
impl Freeze for MqttSnBuilder
impl RefUnwindSafe for MqttSnBuilder
impl Send for MqttSnBuilder
impl Sync for MqttSnBuilder
impl Unpin for MqttSnBuilder
impl UnsafeUnpin for MqttSnBuilder
impl UnwindSafe for MqttSnBuilder
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