Skip to main content

csdif_core/
model.rs

1// SPDX-License-Identifier: MIT
2// Copyright (c) 2025 Egon Kastelijn
3// file: src/model.rs
4
5use serde::{Deserialize, Serialize};
6
7/// Represents a physical sensor used in a CSDIF document.
8#[derive(Debug, Serialize, Deserialize, Clone)]
9pub struct Sensor {
10    pub id: String,
11    pub sensor_type: String,
12    pub unit: String,
13    pub location: Location,
14}
15
16/// Represents a geographic location.
17#[derive(Debug, Serialize, Deserialize, Clone)]
18pub struct Location {
19    pub latitude: f64,
20    pub longitude: f64,
21    pub elevation: Option<f64>,
22}
23
24/// Represents a single observation from a sensor.
25#[derive(Debug, Serialize, Deserialize, Clone)]
26pub struct Observation {
27    pub timestamp: String,
28    pub value: f64,
29    pub sensor_id: String,
30}
31
32/// Represents a full CSDIF document.
33#[derive(Debug, Serialize, Deserialize, Clone)]
34pub struct CsdifDocument {
35    pub sensors: Vec<Sensor>,
36    pub observations: Vec<Observation>,
37}
38
39#[derive(Debug)]
40pub struct StationProfile {
41    pub id: String,
42}