pub struct SyncTopic<'a> { /* private fields */ }
Expand description

A topic destination for messages.

This keeps message parameters for repeatedly publishing to the same topic on a server.

Implementations

Creates a new topic object for publishing messages.

Arguments

cli The client used to publish the messages. topic The topic on which to publish the messages qos The quality of service for messages

Creates a new topic object for publishing messages.

Arguments

cli The client used to publish the messages. topic The topic on which to publish the messages qos The quality of service for messages

Create a message for the topic using the supplied payload

Subscribe to the topic.

Subscribe to the topic with subscription options.

Publish a message on the topic.

If a topic alias was previously sent, this will use the integer alias property instead of sending the topic string. Topic aliases are only applicable for MQTT v5 connections.

Arguments

payload The payload of the message

Publish a message with a topic alias.

This publishes the message with a topic alias property to set the alias at the broker. After calling this, the object keeps the alias and uses it for subsequent publishes instead of sending the full topic string.

Note that using an alias is only valid with an MQTT v5 connection, and the value must be in the range of 1 - TopicAliasMaximum as the broker reported in the CONNACK packet. The alias is only valid for a single connection. It should be reset on a reconnect.

This can be called a second time to change the alias setting. Using an alias of zero on a subsequent call instructs this object to stop using the alias and publish with the topic name.

Arguments

alias The integer alias to use for subsequent message publishing. This must be in the range 1 - TopicAliasMaximum as reported by the server in the CONNACK package. Using a value of zero instructs this object to stop using the alias and go back to publishing with the string topic name. payload The payload of the message

Gets the alias for the topic, if any.

Removes the alias, if any, from the topic.

After removing the alias, publshed messages contain the full string topic. The alias mapping remains on the server though. The alias number cann be reused by assigning to a different topic, but the only way to remove it is to disconnect the client.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.