Skip to main content

PublicationOptions

Struct PublicationOptions 

Source
pub struct PublicationOptions<'p> {
    pub qos: QoS,
    pub retain: bool,
    pub topic: TopicReference<'p>,
    pub payload_format_indicator: Option<bool>,
    pub message_expiry_interval: Option<u32>,
    pub response_topic: Option<TopicName<'p>>,
    pub correlation_data: Option<MqttBinary<'p>>,
    pub content_type: Option<MqttString<'p>>,
}
Expand description

Options for a publication.

Fields§

§qos: QoS

The quality of service that the message is published with to the server. The quality of service level used by the server to send this publication to subscribed clients is the minimum of this value and the quality of service value of the receiving client’s subscription.

§retain: bool

Depicts the value of the retain flag in the PUBLISH packet. If set to 1, the server should retain the message on this topic. Retained messages with quality of service 0 can be discarded at any time by the server.

§topic: TopicReference<'p>

The topic that the message is published on. The topic can be referenced over an existing topic alias mapping or by specifying the topic name and optionally mapping a topic alias to it.

§payload_format_indicator: Option<bool>

Indicates whether the message is valid UTF-8. If None, there is no statement about the UTF-8 character of the message.

§message_expiry_interval: Option<u32>

The message expiry interval in seconds of this application message. After this interval has passed, the server cannot publish this message onward to subscribers. If set to None, the message does not expire and the message expiry interval property is omitted on the network.

§response_topic: Option<TopicName<'p>>

The topic on which the receiver should publish the response.

§correlation_data: Option<MqttBinary<'p>>

Arbitrary binary data which the receiver should attach in the response to associate their response with this request.

§content_type: Option<MqttString<'p>>

The custom content type of the message.

Implementations§

Source§

impl<'p> Options<'p>

Source

pub const fn new(topic: TopicReference<'p>) -> Options<'p>

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

Source

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

Sets the payload format indicator property.

Source

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

Sets the message expiry interval in seconds.

Source

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

Marks the publication as a request by setting the response topic property.

Source

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

Sets the correlation data property in the request.

Source

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

Sets the content type property.

Trait Implementations§

Source§

impl<'p> Clone for Options<'p>

Source§

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

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

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'p> Freeze for Options<'p>

§

impl<'p> RefUnwindSafe for Options<'p>

§

impl<'p> Send for Options<'p>

§

impl<'p> Sync for Options<'p>

§

impl<'p> Unpin for Options<'p>

§

impl<'p> UnsafeUnpin for Options<'p>

§

impl<'p> UnwindSafe for Options<'p>

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.