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: QoSThe 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: boolDepicts 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>
impl<'p> Options<'p>
Sourcepub const fn new(topic: TopicReference<'p>) -> Options<'p>
pub const fn new(topic: TopicReference<'p>) -> Options<'p>
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 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.
Sourcepub const fn message_expiry_interval(self, seconds: u32) -> Self
pub const fn message_expiry_interval(self, seconds: u32) -> Self
Sets the message expiry interval in seconds.
Sourcepub fn response_topic(self, topic: TopicName<'p>) -> Self
pub fn response_topic(self, topic: TopicName<'p>) -> Self
Marks the publication as a request by setting the response topic property.
Sourcepub fn correlation_data(self, data: MqttBinary<'p>) -> Self
pub fn correlation_data(self, data: MqttBinary<'p>) -> Self
Sets the correlation data property in the request.
Sourcepub fn content_type(self, content_type: MqttString<'p>) -> Self
pub fn content_type(self, content_type: MqttString<'p>) -> Self
Sets the content type property.