bms_dtos 0.3.1

Common DTOs for communication over network for the BMS Uni project
Documentation
use serde::{Deserialize, Serialize};
use tokio_postgres::Row;

#[derive(Serialize, Deserialize, Debug)]
pub struct TrendDataRaw {
    pub externallogid: i64,
    pub timestamp: String,
    pub timestamp_tzinfo: i64,
    pub value: Option<f64>,
}

#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct MetadataJson {
    pub externallogid: i64,
    pub source: String,
    pub unit: String,
}

#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct MetadataDb {
    pub log_id: i64,
    pub source: String,
    pub unit: String,
}

impl From<&Row> for MetadataDb {
    fn from(value: &Row) -> MetadataDb {
        let log_id: i64 = value.get("log_id");
        let source: String = value.get("source");
        let unit: String = value.get("unit");

        MetadataDb { log_id, source, unit }
    }
}