aemo_rs/
rooftop_actual.rs1use crate::{FileKeyable, GetFromRawAemo, RawAemoFile, Result};
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Debug, Deserialize, Serialize)]
5pub struct File {
6 header: crate::AemoHeader,
7 actual: Vec<RooftopActual>,
8}
9
10impl crate::AemoFile for File {
11 fn from_raw(RawAemoFile { header, mut data }: RawAemoFile) -> Result<Self> {
12 Ok(Self {
13 header,
14 actual: RooftopActual::from_map(&mut data)?,
15 })
16 }
17}
18
19#[derive(Deserialize, Serialize, Debug, Clone)]
20struct RooftopActual {
21 #[serde(deserialize_with = "crate::au_datetime_deserialize")]
22 interval_datetime: chrono::NaiveDateTime,
23 regionid: String,
24 power: f64,
25 qi: f64,
26 #[serde(rename = "type")]
27 type_: String,
28 #[serde(deserialize_with = "crate::au_datetime_deserialize")]
29 lastchanged: chrono::NaiveDateTime,
30}
31
32impl FileKeyable for RooftopActual {
33 fn key() -> crate::FileKey {
34 ("ROOFTOP".into(), "ACTUAL".into(), 2)
35 }
36}
37
38impl GetFromRawAemo for RooftopActual {
39 type Output = Self;
40}