Skip to main content

MqttSnBuilder

Struct MqttSnBuilder 

Source
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

Source

pub fn new() -> Self

Create a new builder with CONNECT defaults.

Source

pub fn advertise() -> Self

ADVERTISE message builder.

Source

pub fn searchgw() -> Self

SEARCHGW message builder.

Source

pub fn gwinfo() -> Self

GWINFO message builder.

Source

pub fn connect() -> Self

CONNECT message builder.

Source

pub fn connack() -> Self

CONNACK message builder.

Source

pub fn willtopicreq() -> Self

WILLTOPICREQ message builder.

Source

pub fn willtopic() -> Self

WILLTOPIC message builder.

Source

pub fn willmsgreq() -> Self

WILLMSGREQ message builder.

Source

pub fn willmsg() -> Self

WILLMSG message builder.

Source

pub fn register() -> Self

REGISTER message builder.

Source

pub fn regack() -> Self

REGACK message builder.

Source

pub fn publish() -> Self

PUBLISH message builder.

Source

pub fn puback() -> Self

PUBACK message builder.

Source

pub fn pubcomp() -> Self

PUBCOMP message builder.

Source

pub fn pubrec() -> Self

PUBREC message builder.

Source

pub fn pubrel() -> Self

PUBREL message builder.

Source

pub fn subscribe() -> Self

SUBSCRIBE message builder.

Source

pub fn suback() -> Self

SUBACK message builder.

Source

pub fn unsubscribe() -> Self

UNSUBSCRIBE message builder.

Source

pub fn unsuback() -> Self

UNSUBACK message builder.

Source

pub fn pingreq() -> Self

PINGREQ message builder.

Source

pub fn pingresp() -> Self

PINGRESP message builder.

Source

pub fn disconnect() -> Self

DISCONNECT message builder.

Source

pub fn willtopicupd() -> Self

WILLTOPICUPD message builder.

Source

pub fn willtopicresp() -> Self

WILLTOPICRESP message builder.

Source

pub fn willmsgupd() -> Self

WILLMSGUPD message builder.

Source

pub fn willmsgresp() -> Self

WILLMSGRESP message builder.

Source

pub fn msg_type(self, v: u8) -> Self

Set the message type byte directly.

Source

pub fn dup(self, v: bool) -> Self

Set the DUP flag.

Source

pub fn qos(self, v: u8) -> Self

Set the QoS level (0-3).

Source

pub fn retain(self, v: bool) -> Self

Set the Retain flag.

Source

pub fn will(self, v: bool) -> Self

Set the Will flag.

Source

pub fn cleansess(self, v: bool) -> Self

Set the CleanSession flag.

Source

pub fn tid_type(self, v: u8) -> Self

Set the TopicIdType (0-3).

Source

pub fn gw_id(self, v: u8) -> Self

Set the Gateway ID.

Source

pub fn duration(self, v: u16) -> Self

Set the Duration.

Source

pub fn radius(self, v: u8) -> Self

Set the Radius.

Source

pub fn gw_addr(self, v: &[u8]) -> Self

Set the Gateway Address.

Source

pub fn prot_id(self, v: u8) -> Self

Set the Protocol ID.

Source

pub fn client_id(self, v: &[u8]) -> Self

Set the Client ID (byte slice).

Source

pub fn client_id_str(self, v: &str) -> Self

Set the Client ID from a string.

Source

pub fn return_code(self, v: u8) -> Self

Set the Return Code.

Source

pub fn tid(self, v: u16) -> Self

Set the Topic ID.

Source

pub fn mid(self, v: u16) -> Self

Set the Message ID.

Source

pub fn data(self, v: &[u8]) -> Self

Set the Data / payload bytes.

Source

pub fn topic_name(self, v: &[u8]) -> Self

Set the Topic Name.

Source

pub fn topic_name_str(self, v: &str) -> Self

Set the Topic Name from a string.

Source

pub fn will_topic_bytes(self, v: &[u8]) -> Self

Set the Will Topic.

Source

pub fn will_topic_str(self, v: &str) -> Self

Set the Will Topic from a string.

Source

pub fn will_msg_bytes(self, v: &[u8]) -> Self

Set the Will Message.

Source

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
Source

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

Source§

fn clone(&self) -> MqttSnBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MqttSnBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MqttSnBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl IntoLayerStackEntry for MqttSnBuilder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V