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