//! Interface to a publish values via MQTT.

use protocol::{Location, Value};

// TODO: Configuration mechanism.

/// Interface to MQTT.
pub struct Publish {
    // TODO
}

impl Publish {
    /// Initializes the connection to MQTT.
    ///
    /// The function does not return an error. Instead, the code will automatically retry
    /// connection in case the connection cannot be established or the server closes the
    /// connection.
    pub fn init() -> Publish {
        // TODO
        Publish {}
    }

    /// Publishes values received from a device.
    ///
    /// If there is no current connection to MQTT and the connection cannot be reestablished before
    /// the application is stopped, the values are lost. If multiple calls to this function occur
    /// while there is no current connection to MQTT, only the latest values are published.
    ///
    /// # Arguments
    ///
    /// * `location` - the location of the device
    /// * `values` - a list of values to be published
    pub async fn publish(&mut self, _location: Location, _values: &[Value]) {
        // TODO
    }
}
