Skip to main content

river_data_core/models/
backend.rs

1use chrono::{DateTime, Utc};
2use uuid::Uuid;
3
4use crate::models::streams::{IngestReading, IngestStatusEvent};
5
6/// Describes a data stream to register with river-data.
7#[derive(Debug, Clone)]
8pub struct StreamDescriptor {
9    /// Unique key within the source system (ie. a location id or column name).
10    pub source_key: String,
11    /// Human-readable name shown in the dashboard.
12    pub source_name: String,
13    /// Hierarchy path (ie. "cnet/VAD/WTW_DO_mgL_1"), parsed server-side for site discovery.
14    pub source_path: String,
15    pub metadata: serde_json::Value,
16    /// Stream classification ('spot' or 'continuous'); None defers to the API's resolution chain.
17    pub measurement_type: Option<String>,
18}
19
20/// Asks a backend for readings for one stream since a cursor.
21#[derive(Debug, Clone)]
22pub struct StreamFetchRequest {
23    pub stream_id: Uuid,
24    pub source_key: String,
25    /// Last known reading time. None on a new stream or a full sync.
26    pub since: Option<DateTime<Utc>>,
27}
28
29/// Readings fetched for one stream, ready to ingest.
30#[derive(Debug)]
31pub struct StreamReadings {
32    pub stream_id: Uuid,
33    pub source_key: String,
34    pub readings: Vec<IngestReading>,
35}
36
37/// Status events fetched for one stream.
38#[derive(Debug)]
39pub struct StreamStatusEvents {
40    pub stream_id: Uuid,
41    pub source_key: String,
42    pub events: Vec<IngestStatusEvent>,
43}