Skip to main content

Meter

Struct Meter 

Source
pub struct Meter<'a, const N: usize> { /* private fields */ }
Expand description

A virtual electricity meter with an exact import register and N retained observations.

Implementations§

Source§

impl<'a, const N: usize> Meter<'a, N>

Source

pub const CAPACITY: usize = N

Maximum number of local register observations.

Source

pub fn new(id: &'a str, utc: i64, import_dwh: u32) -> Result<Self, Error>

Start with one observed opening register value.

Source

pub fn id(&self) -> &'a str

Source

pub fn current(&self) -> Reading

Most recently observed register, including the opening value.

Source

pub fn advance(&mut self, utc: i64, delta_dwh: u32) -> Result<Reading, Error>

Add measured consumption. A successful observation may evict the oldest row.

Source

pub fn readings(&self) -> impl Iterator<Item = Reading> + Clone + '_

Retained observations from oldest to newest.

Source

pub fn usage(&self, first: i64, last: i64) -> Option<u32>

Exact consumption between two retained observations, in deci-Wh. Missing endpoints and reversed intervals return None.

Trait Implementations§

Source§

impl<'a, const N: usize> Clone for Meter<'a, N>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, const N: usize> Debug for Meter<'a, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, const N: usize> Freeze for Meter<'a, N>

§

impl<'a, const N: usize> RefUnwindSafe for Meter<'a, N>

§

impl<'a, const N: usize> Send for Meter<'a, N>

§

impl<'a, const N: usize> Sync for Meter<'a, N>

§

impl<'a, const N: usize> Unpin for Meter<'a, N>

§

impl<'a, const N: usize> UnsafeUnpin for Meter<'a, N>

§

impl<'a, const N: usize> UnwindSafe for Meter<'a, N>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.