Struct WillOptions
#[non_exhaustive]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 payload_format: Option<PayloadFormat>,
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 (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.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).
payload_format: Option<PayloadFormat>Whether the payload is UTF-8 encoded (property 0x01).
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
Creates 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
Sets 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
Sets the message expiry interval in seconds (property 0x02).
pub fn content_type(self, ct: MqttString) -> Self
pub fn content_type(self, ct: MqttString) -> Self
Sets the content type (property 0x03).
pub fn response_topic(self, topic: TopicBuf) -> Self
pub fn response_topic(self, topic: TopicBuf) -> Self
Sets the response topic (property 0x08).
pub fn correlation_data(self, data: MqttBytesBuf) -> Self
pub fn correlation_data(self, data: MqttBytesBuf) -> Self
Sets correlation data (property 0x09).
pub const fn payload_format(self, format: PayloadFormat) -> Self
pub const fn payload_format(self, format: PayloadFormat) -> Self
Sets the payload format indicator (property 0x01).
pub fn user_property(self, key: MqttString, value: MqttString) -> Self
pub fn user_property(self, key: MqttString, value: MqttString) -> Self
Adds 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§
impl Freeze for WillOptions
impl RefUnwindSafe for WillOptions
impl Send for WillOptions
impl Sync for WillOptions
impl Unpin for WillOptions
impl UnwindSafe for WillOptions
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more