ee8ed0c6443beb1ebfea308eccf128fac9a47e71
Naturally, we need a way to configure the MQTT connection parameters (host, port, username, etc.). For that, we'll use a TOML configuration file, which is read at startup and deserialized into a structure owned by the Session. The Session object now has a `run` method, which establishes the MQTT connection and then repeatedly waits for messages from the broker. It will continuously attempt to connect to the broker until it succeeds. This way, if the broker is unavailable when the application starts, it will eventually connect when it becomes available. Once the initial connection is established, the client will automatically reconnect if it gets disconnected later. Since the `run` method loops forever and never returns, we need to use a separate Tokio task to manage it. We keep the task handle so we can cancel the task when the application shuts down.
Description
No description provided
Languages
Rust
99.9%
Shell
0.1%