Skip to main content

WillOptions

Struct WillOptions 

Source
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: QoS

The quality of service that the server publishes the will message with in place of the client.

§will_retain: bool

The 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: u32

The 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>

Source

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.

Source

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

Sets the Quality of Service level.

Source

pub const fn at_least_once(self) -> Self

Sets the Quality of Service level to 1 (At Least Once).

Source

pub const fn exactly_once(self) -> Self

Sets the Quality of Service level to 1 (Exactly Once).

Source

pub const fn retain(self) -> Self

Sets the retain flag in the will message to true.

Source

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

Sets the delay in seconds after which the will message is published.

Source

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.

Source

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

Sets the message expiry interval in seconds of the will message.

Source

pub fn content_type(self, content_type: MqttString<'c>) -> Self

Sets a custom content type of the will message.

Source

pub fn response_topic(self, response_topic: TopicName<'c>) -> Self

Marks the will message as a request by setting the response topic property.

Source

pub fn correlation_data(self, correlation_data: MqttBinary<'c>) -> Self

Sets the correlation data property in the request.

Trait Implementations§

Source§

impl<'c> Clone for Options<'c>

Source§

fn clone(&self) -> Options<'c>

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<'c> Debug for Options<'c>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'c> Freeze for Options<'c>

§

impl<'c> RefUnwindSafe for Options<'c>

§

impl<'c> Send for Options<'c>

§

impl<'c> Sync for Options<'c>

§

impl<'c> Unpin for Options<'c>

§

impl<'c> UnsafeUnpin for Options<'c>

§

impl<'c> UnwindSafe for Options<'c>

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