iadb_api/
schemas.rs

1use std::fmt;
2use serde::{Serialize, Deserialize};
3
4
5#[derive(Serialize, Deserialize)]
6/// Data series.
7pub struct IADBSeries {
8    /// IADB series code. 
9    pub name: String,
10    pub data: Vec<IADBDataPoint>,
11}
12
13impl fmt::Display for IADBSeries {
14    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15        write!(f, "IADB Series ({})\n", self.name)?;
16        for item in self.data.iter() {
17            write!(f, "{}\n", item.to_string())?;
18        }
19        Ok(())
20    }
21}
22
23
24#[derive(Serialize, Deserialize)]
25/// Describes a single entry in the series.
26pub struct IADBDataPoint {
27    // #[serde(rename = "DATE")]
28    /// Date of the data point.
29    pub date: String,
30    /// Value of the data point.
31    pub value: f64,
32}
33
34impl fmt::Display for IADBDataPoint {
35    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
36        write!(f, "IADB Data Point ({}): {}", self.date, self.value)
37    }
38}