Trait drmem_api::Store

source ·
pub trait Store {
    // Required methods
    fn register_read_only_device<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 mut self,
        driver: &'life1 str,
        name: &'life2 Name,
        units: &'life3 Option<String>,
        max_history: &'life4 Option<usize>
    ) -> Pin<Box<dyn Future<Output = Result<(ReportReading<Value>, Option<Value>)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn register_read_write_device<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 mut self,
        driver: &'life1 str,
        name: &'life2 Name,
        units: &'life3 Option<String>,
        max_history: &'life4 Option<usize>
    ) -> Pin<Box<dyn Future<Output = Result<(ReportReading<Value>, RxDeviceSetting, Option<Value>)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn get_device_info<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        pattern: &'life1 Option<String>
    ) -> Pin<Box<dyn Future<Output = Result<Vec<DevInfoReply>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn set_device<'life0, 'async_trait>(
        &'life0 self,
        name: Name,
        value: Value
    ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_setting_chan<'life0, 'async_trait>(
        &'life0 self,
        name: Name,
        own: bool
    ) -> Pin<Box<dyn Future<Output = Result<TxDeviceSetting>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn monitor_device<'life0, 'async_trait>(
        &'life0 mut self,
        name: Name,
        start: Option<DateTime<Utc>>,
        end: Option<DateTime<Utc>>
    ) -> Pin<Box<dyn Future<Output = Result<DataStream<Reading>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Defines the trait that a back-end needs to implement to provide storage for – and access to – the state of each driver’s devices.

Required Methods§

source

fn register_read_only_device<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, driver: &'life1 str, name: &'life2 Name, units: &'life3 Option<String>, max_history: &'life4 Option<usize> ) -> Pin<Box<dyn Future<Output = Result<(ReportReading<Value>, Option<Value>)>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Called when a read-only device is to be registered with the back-end.

When drmemd begins, it starts up the set of drivers specified in the configuration file. As these drivers initialize, they’ll register the devices they need. For read-only devices, this method will be called.

  • driver is the name of the driver. The framework will guarantee that this parameter is consistent for all devices defined by a driver.
  • name is the full name of the device.
  • units is an optional value which specifies the engineering units returned by the device.
  • max_history is a hint as to how large an archive the user specifies should be used for this device.

On success, this function returns a pair. The first element is a closure the driver uses to report updates. The second element is an optional value representing the last value of the device, as saved in the back-end.

source

fn register_read_write_device<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, driver: &'life1 str, name: &'life2 Name, units: &'life3 Option<String>, max_history: &'life4 Option<usize> ) -> Pin<Box<dyn Future<Output = Result<(ReportReading<Value>, RxDeviceSetting, Option<Value>)>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Called when a read-write device is to be registered with the back-end.

When drmemd begins, it starts up the set of drivers specified in the configuration file. As these drivers initialize, they’ll register the devices they need. For read-write devices, this method will be called.

  • driver is the name of the driver. The framework will guarantee that this parameter is consistent for all devices defined by a driver.
  • name is the full name of the device.
  • units is an optional value which specifies the engineering units returned by the device.
  • max_history is a hint as to how large an archive the user specifies should be used for this device.

On success, this function returns a 3-tuple. The first element is a closure the driver uses to report updates. The second element is a handle with which the driver will receive setting requests. The third element is an optional value representing the last value of the device, as saved in the back-end.

source

fn get_device_info<'life0, 'life1, 'async_trait>( &'life0 mut self, pattern: &'life1 Option<String> ) -> Pin<Box<dyn Future<Output = Result<Vec<DevInfoReply>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called when information from a device is requested.

On success, this method should return an array of client::DevInfoReply data. If a pattern is specified, only device names matching the pattern should be returned. The grammar of the pattern is the one used by Redis (to be consistent across back-ends.)

source

fn set_device<'life0, 'async_trait>( &'life0 self, name: Name, value: Value ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Sends a request to a driver to set its device to the specified value.

source

fn get_setting_chan<'life0, 'async_trait>( &'life0 self, name: Name, own: bool ) -> Pin<Box<dyn Future<Output = Result<TxDeviceSetting>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Obtains the mpsc::Sender<> handle associated with the specified device. This handle can be used to send settings to the device. If ’ownis set totrue, the requester will be the only one that can send settings to the device. NOTE: own` is currently unsupported and should always be set to ‘false’. When it gets supported, requesters can decide whether they should set it to true.

source

fn monitor_device<'life0, 'async_trait>( &'life0 mut self, name: Name, start: Option<DateTime<Utc>>, end: Option<DateTime<Utc>> ) -> Pin<Box<dyn Future<Output = Result<DataStream<Reading>>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Creates a stream that yields values of a device as it updates.

Implementors§