Crate paho_mqtt

Source
Expand description

This is the Eclipse Paho MQTT client library for the Rust language.

§Crate Features

§Default

  • bundled Builds the Paho C library for the target and automatically links it.

  • ssl Builds the library with OpenSSL support. This allow secure SSL/TLS connections to a broker along with secure websockets. This requires OpenSSL to be installed for the target or using the vendored-ssl feature to build it.

§Non-default

  • build_bindgen Build the bindings to the Paho C library for the target. The library ships with a number of pre-built bindings for common targets. For other targets it might be helpful to build the bindings for the specific target platform, especially if the library segfauls due to an improper API.

  • vendored-ssl Download an build OpenSSL for the target.

§Logging

The library uses the standard Rust log facility with the target/module “paho_mqtt”.

In addition, the traces from the underlying Paho C library are captured and redirected to the Rust log facility. Since the C library is a bit cryptic and verbose, the output is controlled separately using a “paho_mqtt_c” target/module. The levels for the C library are approximated to suit the Rust filter level selected for it.

The example applications use the simple environment logger which can be controlled by the RUST_LOG environment variable. To set the logging for the two modules, you can do something like:

$ RUST_LOG="pago_mqtt=info,paho_mqtt_c=debug" ./target/debug/examples/async_subscribe
Connecting to the MQTT server at 'mqtt://localhost:1883'...
[2023-09-11T13:26:18Z DEBUG paho_mqtt::c_trace] =========================================================
[2023-09-11T13:26:18Z DEBUG paho_mqtt::c_trace]                    Trace Output
[2023-09-11T13:26:18Z DEBUG paho_mqtt::c_trace] Product name: Eclipse Paho Asynchronous MQTT C Client Library
[2023-09-11T13:26:18Z DEBUG paho_mqtt::c_trace] Version: 1.3.11
...

Re-exports§

pub use crate::topic_matcher::TopicMatcher;
pub use crate::async_client::*;
pub use crate::client::*;
pub use crate::client_persistence::*;
pub use crate::connect_options::*;
pub use crate::create_options::*;
pub use crate::disconnect_options::*;
pub use crate::errors::*;
pub use crate::message::*;
pub use crate::name_value::*;
pub use crate::properties::*;
pub use crate::reason_code::*;
pub use crate::response_options::*;
pub use crate::server_response::*;
pub use crate::ssl_options::*;
pub use crate::subscribe_options::*;
pub use crate::token::*;
pub use crate::topic::*;
pub use crate::types::*;
pub use crate::will_options::*;

Modules§

async_client
The asynchronous API The Asynchronous client module for the Paho MQTT Rust client library.
client
The synchronous API This contains the synchronous Client interface for the Paho MQTT Rust library.
client_persistence
Definitions for creating user-defined persistence.
connect_options
Options for connecting to the server. Connect options for the Paho MQTT Rust client library.
create_options
Client creation options
disconnect_options
Options for disconnecting from the server. Disconnect options for the Paho MQTT Rust client library. This contains the structures to define the options for disconnecting from the MQTT broker/server.
errors
The MQTT errors
message
The message object
name_value
Utility for creating name/value string pair collections (to pass to the C library).
properties
MQTT 5v properties. MQTT v5 properties.
reason_code
MQTT v5 Reason Codes The Reason Code module for the Paho MQTT Rust client library.
response_options
Options for responses coming back from the C lib. Response options for the Paho MQTT Rust client library.
server_response
Responses coming back from the server. The Token module for the Paho MQTT Rust client library.
ssl_options
Connect options for creating secure connections to the server.
string_collection
Utility for creating string collections (to pass to the C library).
subscribe_options
Options for subscribing to topics MQTT v5 subscribe options for the Paho MQTT Rust client library. These are defined in section 3.8.3.1 of the MQTT v5 spec. The defaults use the behavior that was present in MQTT v3.1.1.
token
Tokens to monitor asynchronous operations The Token module for the Paho MQTT Rust client library.
topic
Options for creating topic objects that are associated with a particular server. Objects for manipulating and checking message topics.
topic_matcher
Code to match MQTT topics to filters that may contain wildcards.
types
Miscelaneous types MQTT support types
will_options
Connect options for the Last Will and Testament (LWT) message. Last Will and Testament (LWT) options for the Paho MQTT Rust client library.

Macros§

properties
Creates a collection of properties
topic_matcher
Macro to create a TopicMatcher collection.

Structs§

AsyncReceiver
The receiving side of a channel.
Receiver
The receiving side of a channel.

Functions§

from_c_bool
Converts a C integer boolean to a Rust bool
is_secure_uri
Determines if the URI us for a secure connection.
to_c_bool
Convert a Rust bool to a Paho C integer boolean

Type Aliases§

UserData
Generic type for arbitrary user-supplied data.