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: TopicBufTopic to publish the will message on.
payload: MqttBytesBufWill message payload.
qos: QoSQuality of Service for the will message.
retain: boolWhether 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
impl WillOptions
pub const fn new(topic: TopicBuf, payload: MqttBytesBuf) -> Self
pub const fn new(topic: TopicBuf, payload: MqttBytesBuf) -> Self
Create a will message with a topic and payload.
pub const fn delay_interval(self, seconds: u32) -> Self
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
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
pub fn content_type(self, ct: MqttString) -> Self
Set the content type (property 0x03).
pub fn response_topic(self, topic: TopicBuf) -> Self
pub fn response_topic(self, topic: TopicBuf) -> Self
Set the response topic (property 0x08).
pub fn correlation_data(self, data: MqttBytesBuf) -> Self
pub fn correlation_data(self, data: MqttBytesBuf) -> Self
Set correlation data (property 0x09).
pub fn user_property(self, key: MqttString, value: MqttString) -> Self
pub fn user_property(self, key: MqttString, value: MqttString) -> Self
Add a user property (property 0x26). May be called multiple times.