pub struct Client { /* private fields */ }
Expand description

MQTT Client with a synchronous (blocking) API. This is simply a convenience wrapper around the asynchronous API, providing blocking calls with timeouts.

Implementations

Creates a new MQTT client which can connect to an MQTT broker.

Gets the default timeout used for synchronous operations.

Sets the default timeout used for synchronous operations.

Arguments

timeout The timeout to use for synchronous calls, like connect(), disconnect(), publish(), etc.

Connects to an MQTT broker using the specified connect options.

Disconnects from the MQTT broker.

Arguments

opt_opts Optional disconnect options. Specifying None will use default of immediate (zero timeout) disconnect.

Disconnect from the MQTT broker with a timeout. This will delay the disconnect for up to the specified timeout to allow in-flight messages to complete. This is the same as calling disconnect with options specifying a timeout.

Arguments

timeout The amount of time to wait for the disconnect. This has a resolution in milliseconds.

Attempts to reconnect to the broker. This can only be called after a connection was initially made or attempted. It will retry with the same connect options.

Determines if this client is currently connected to an MQTT broker.

Publishes a message to an MQTT broker

Subscribes to a single topic.

Arguments

topic The topic name qos The quality of service requested for messages

Subscribes to a single topic with v5 options

Arguments

topic The topic name qos The quality of service requested for messages opts Options for the subscription props MQTT v5 properties

Subscribes to multiple topics simultaneously.

Arguments

topic The topic name qos The quality of service requested for messages

Subscribes to multiple topics simultaneously with options.

Arguments

topics The collection of topic names qos The quality of service requested for messages opts Subscribe options (one per topic) props MQTT v5 properties

Unsubscribes from a single topic.

Arguments

topic The topic to unsubscribe. It must match a topic from a previous subscribe.

Unsubscribes from a single topic.

Arguments

topic The topic to unsubscribe. It must match a topic from a previous subscribe. props MQTT v5 properties for the unsubscribe.

Unsubscribes from multiple topics simultaneously.

Arguments

topic The topics to unsubscribe. Each must match a topic from a previous subscribe.

Unsubscribes from multiple topics simultaneously.

Arguments

topic The topics to unsubscribe. Each must match a topic from a previous subscribe. props MQTT v5 properties for the unsubscribe.

Starts the client consuming messages.

This starts the client receiving messages and placing them into an mpsc queue. It returns the receiving-end of the queue for the application to get the messages. This can be called at any time after the client is created, but it should be called before subscribing to any topics, otherwise messages can be lost.

Stops the client consumer.

Returns client ID used for client instance

Client ID is returned as a rust String as set in a CreateOptionsBuilder for symmetry

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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 resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

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.