Struct HeatingStatsEntry

Source
pub struct HeatingStatsEntry {
    pub date: NaiveDate,
    pub energy: f64,
    pub ambient_temperature_average_value: f64,
    pub ambient_temperature_average_counter: i64,
    pub water_temperature_average_value: f64,
    pub water_temperature_average_counter: i64,
    pub heating_control_runtime: i64,
}
Expand description

Holds the statistical data of heating for one day. It is filled with post-processed data from a database query which is then updated by the control application.

Fields§

§date: NaiveDate

calendar date of the entry after having postprocessed the SQL data read as String

§energy: f64

energy used for heating on a specific date in kWh

§ambient_temperature_average_value: f64

average ambient temperature value on a specific date in °C

§ambient_temperature_average_counter: i64

counter how many samples were used to calculate the average value

§water_temperature_average_value: f64

average water temperature value on a specific date in °C

§water_temperature_average_counter: i64

counter how many samples were used to calculate the average value

§heating_control_runtime: i64

counter how many seconds the heating control was active on a specific date

Implementations§

Source§

impl HeatingStatsEntry

Source

pub fn new(conn: &mut PooledConn) -> HeatingStatsEntry

Creates a new HeatingStatsEntry initialized for the current local date.

This constructor is used when there’s no existing heating statistics record for the current day in the database. It sets the date field to today’s date and initializes all statistical counters and values to zero.

§Returns

A new HeatingStatsEntry struct with default values for the current date.

Source

pub fn update( &mut self, water_temperature_opt: Option<f64>, ambient_temperature_opt: Option<f64>, energy_increment: f64, )

Updates the heating statistics entry with new sensor readings and energy consumption data.

This method incorporates new samples to incrementally calculate average water and ambient temperatures, sum up energy consumption, and track the heating control’s active runtime.

§Arguments
  • water_temperature_opt - An Option<f64> representing the latest water temperature reading. If Some, it contributes to the average; if None, the water temperature average remains unchanged.
  • ambient_temperature_opt - An Option<f64> representing the latest ambient air temperature reading. If Some, it contributes to the average; if None, the ambient temperature average remains unchanged.
  • energy_increment - The amount of energy (in kWh) consumed by the heater since the last update.

Trait Implementations§

Source§

impl Clone for HeatingStatsEntry

Source§

fn clone(&self) -> HeatingStatsEntry

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Display for HeatingStatsEntry

Source§

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

Formats the HeatingStatsEntry struct into a multi-line, human-readable string.

This implementation is primarily intended for debugging and logging, providing a clear overview of the heating statistics for a given date, including average temperatures, energy consumption, and control runtime.

§Arguments
  • f - A mutable reference to the formatter, as required by the fmt::Display trait.
§Returns

A fmt::Result indicating whether the formatting operation was successful.

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T