WillOptions

Struct WillOptions 

pub struct WillOptions {
    pub topic: TopicBuf,
    pub payload: MqttBytesBuf,
    pub qos: QoS,
    pub retain: bool,
    pub delay_interval: Option<u32>,
    pub message_expiry: Option<u32>,
    pub content_type: Option<MqttString>,
    pub response_topic: Option<TopicBuf>,
    pub correlation_data: Option<MqttBytesBuf>,
    pub user_properties: Vec<(MqttString, MqttString)>,
}
Expand description

Configuration for the MQTT will message (Last Will and Testament).

If set, the broker publishes this message when the client disconnects ungracefully.

Fields§

§topic: TopicBuf

Topic to publish the will message on.

§payload: MqttBytesBuf

Will message payload.

§qos: QoS

Quality of Service for the will message.

§retain: bool

Whether the will message should be retained.

§delay_interval: Option<u32>

Will delay interval in seconds (property 0x18). Delays publishing the will after disconnect.

§message_expiry: Option<u32>

Message expiry interval in seconds (property 0x02).

§content_type: Option<MqttString>

Content type (property 0x03).

§response_topic: Option<TopicBuf>

Response topic for request/response (property 0x08).

§correlation_data: Option<MqttBytesBuf>

Correlation data for request/response (property 0x09).

§user_properties: Vec<(MqttString, MqttString)>

User properties (property 0x26).

Implementations§

§

impl WillOptions

pub const fn new(topic: TopicBuf, payload: MqttBytesBuf) -> Self

Create a will message with a topic and payload.

pub const fn qos(self, qos: QoS) -> Self

Set the Quality of Service for the will message.

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

Set the retain flag for the will message.

pub const fn delay_interval(self, seconds: u32) -> Self

Set the will delay interval in seconds (property 0x18).

pub const fn message_expiry(self, seconds: u32) -> Self

Set the message expiry interval in seconds (property 0x02).

pub fn content_type(self, ct: MqttString) -> Self

Set the content type (property 0x03).

pub fn response_topic(self, topic: TopicBuf) -> Self

Set the response topic (property 0x08).

pub fn correlation_data(self, data: MqttBytesBuf) -> Self

Set correlation data (property 0x09).

pub fn user_property(self, key: MqttString, value: MqttString) -> Self

Add a user property (property 0x26). May be called multiple times.

fn iter_properties(&self) -> impl Iterator<Item = Property<'_>>

pub(crate) fn to_properties( &self, ) -> Result<WillPropertiesBuf, PropertiesBufError>

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> 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, 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.