pub struct MeterRegistry {
meters: Vec<MeterDescriptor>,
cache: HashMap<Vec<u8>, Vec<(ObisCode, u8, CosemDataType)>>,
}Expand description
The configured meter list plus a per-meter aggregation cache.
Fields§
§meters: Vec<MeterDescriptor>§cache: HashMap<Vec<u8>, Vec<(ObisCode, u8, CosemDataType)>>Cached last-read values: meter_id → list of (obis, attribute, value).
Implementations§
Source§impl MeterRegistry
impl MeterRegistry
Sourcepub fn add(&mut self, meter: MeterDescriptor)
pub fn add(&mut self, meter: MeterDescriptor)
Adds a meter, replacing any existing entry with the same meter_id.
Sourcepub fn remove(&mut self, meter_id: &[u8])
pub fn remove(&mut self, meter_id: &[u8])
Removes a meter and all its cached data (§10.2: related data is removed).
Sourcepub fn find(&self, meter_id: &[u8]) -> Option<&MeterDescriptor>
pub fn find(&self, meter_id: &[u8]) -> Option<&MeterDescriptor>
Looks up a meter by its identifier.
Sourcepub fn meters(&self) -> &[MeterDescriptor]
pub fn meters(&self) -> &[MeterDescriptor]
The configured meters.
Sourcepub fn store(
&mut self,
meter_id: &[u8],
obis: ObisCode,
attribute: u8,
value: CosemDataType,
)
pub fn store( &mut self, meter_id: &[u8], obis: ObisCode, attribute: u8, value: CosemDataType, )
Stores (or updates) a cached attribute value read from a meter.
Sourcepub fn cached(
&self,
meter_id: &[u8],
obis: &ObisCode,
attribute: u8,
) -> Option<&CosemDataType>
pub fn cached( &self, meter_id: &[u8], obis: &ObisCode, attribute: u8, ) -> Option<&CosemDataType>
Returns a cached attribute value, if present.
Sourcepub fn build_meter_list(&self) -> Data
pub fn build_meter_list(&self) -> Data
Builds the COSEM meter-list Data (IC 1) object (§10.2, 0.0.94.7.128.255).
Trait Implementations§
Source§impl Clone for MeterRegistry
impl Clone for MeterRegistry
Source§fn clone(&self) -> MeterRegistry
fn clone(&self) -> MeterRegistry
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MeterRegistry
impl Debug for MeterRegistry
Source§impl Default for MeterRegistry
impl Default for MeterRegistry
Source§fn default() -> MeterRegistry
fn default() -> MeterRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MeterRegistry
impl RefUnwindSafe for MeterRegistry
impl Send for MeterRegistry
impl Sync for MeterRegistry
impl Unpin for MeterRegistry
impl UnsafeUnpin for MeterRegistry
impl UnwindSafe for MeterRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more