pub struct WillOptions<'c> {
pub will_qos: QoS,
pub will_retain: bool,
pub will_topic: TopicName<'c>,
pub will_delay_interval: u32,
pub payload_format_indicator: Option<bool>,
pub message_expiry_interval: Option<u32>,
pub content_type: Option<MqttString<'c>>,
pub response_topic: Option<TopicName<'c>>,
pub correlation_data: Option<MqttBinary<'c>>,
pub will_message: MqttBinary<'c>,
}Expand description
Options for configuring the client’s will or last will in a session. The server can publish a single PUBLISH packet in place of the client. This process behaves as if the will message was published by the client. The will is published at the earlier of the following scenarios:
- The session of the client ends.
- The will delay interval passes.
Fields§
§will_qos: QoSThe quality of service that the server publishes the will message with in place of the client.
will_retain: boolThe value of the retain flag of the will message published by the server in place of the client.
will_topic: TopicName<'c>The topic of the will publication.
will_delay_interval: u32The interval in seconds that passes after a disconnection before the server publishes the will. The session of the client does not necessarily have to end for this scenario to happen. The client can reconnect before this interval has passed to prevent the will publication. If the value of the will delay interval is 0, the property is omitted on the network.
payload_format_indicator: Option<bool>The payload format indicator property in the will publication. If present, this indicates
whether the will payload is valid UTF-8. If set to None, the property is omitted on the
network.
message_expiry_interval: Option<u32>The message expiry interval in seconds of the will publication. If set to None, the message
does not expire and the message expiry interval property is omitted on the network.
content_type: Option<MqttString<'c>>The content type property in the will publication. If set to None, the property is omitted
on the network.
response_topic: Option<TopicName<'c>>The response topic property in the will publication. If set to None, the property is omitted
on the network.
correlation_data: Option<MqttBinary<'c>>The correlation data property in the will publication. If set to None, the property is omitted
on the network.
will_message: MqttBinary<'c>The payload of the will publication.
Implementations§
Source§impl<'c> Options<'c>
impl<'c> Options<'c>
Sourcepub const fn new(topic: TopicName<'c>, message: MqttBinary<'c>) -> Options<'c>
pub const fn new(topic: TopicName<'c>, message: MqttBinary<'c>) -> Options<'c>
Creates options with values coherent to the Default implementations of the fields and
QoS::AtMostOnce.
Sourcepub const fn at_least_once(self) -> Self
pub const fn at_least_once(self) -> Self
Sets the Quality of Service level to 1 (At Least Once).
Sourcepub const fn exactly_once(self) -> Self
pub const fn exactly_once(self) -> Self
Sets the Quality of Service level to 1 (Exactly Once).
Sourcepub const fn delay_interval(self, delay_interval: u32) -> Self
pub const fn delay_interval(self, delay_interval: u32) -> Self
Sets the delay in seconds after which the will message is published.
Sourcepub const fn payload_format_indicator(self, is_payload_utf8: bool) -> Self
pub const fn payload_format_indicator(self, is_payload_utf8: bool) -> Self
Sets the payload format indicator property to true thus marking the payload of the will message. as valid UTF-8.
Sourcepub const fn message_expiry_interval(self, message_expiry_interval: u32) -> Self
pub const fn message_expiry_interval(self, message_expiry_interval: u32) -> Self
Sets the message expiry interval in seconds of the will message.
Sourcepub fn content_type(self, content_type: MqttString<'c>) -> Self
pub fn content_type(self, content_type: MqttString<'c>) -> Self
Sets a custom content type of the will message.
Sourcepub fn response_topic(self, response_topic: TopicName<'c>) -> Self
pub fn response_topic(self, response_topic: TopicName<'c>) -> Self
Marks the will message as a request by setting the response topic property.
Sourcepub fn correlation_data(self, correlation_data: MqttBinary<'c>) -> Self
pub fn correlation_data(self, correlation_data: MqttBinary<'c>) -> Self
Sets the correlation data property in the request.