pub struct MqttClient<Settings, Stack, Clock, const MESSAGE_SIZE: usize> where
    Settings: Miniconf + Clone,
    Stack: TcpClientStack,
    Clock: Clock
{ /* private fields */ }
Expand description

MQTT settings interface.

Implementations

Construct a new MQTT settings interface.

Args
  • stack - The network stack to use for communication.
  • client_id - The ID of the MQTT client. May be an empty string for auto-assigning.
  • prefix - The MQTT device prefix to use for this device.
  • broker - The IP address of the MQTT broker to use.
  • clock - The clock for managing the MQTT connection.
  • settings - The initial settings values.

Update the MQTT interface and service the network. Pass any settings changes to the handler supplied.

Args
  • handler - A closure called with updated settings that can be used to apply current settings or validate the configuration. Arguments are (path, old_settings, new_settings).
Example
#[derive(miniconf::Miniconf, Clone)]
struct Settings {
    threshold: u32,
}


// let mut client = miniconf::MqttClient::new(...);
client.handled_update(|path, old_settings, new_settings| {
    if new_settings.threshold > 5 {
        return Err("Requested threshold too high");
    }

    *old_settings = new_settings.clone();

    Ok(())
}).unwrap();
Returns

True if the settings changed. False otherwise.

Update the settings from the network stack without any specific handling.

Returns

True if the settings changed. False otherwise

Get the current settings from miniconf.

Force republication of the current settings.

Note

This is intended to be used if modification of a setting had side effects that affected another setting.

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.