use chrono::{DateTime, Utc};
use uuid::Uuid;
use crate::models::annotations::AnnotationUpsert;
use crate::models::replicates::{GroupAudit, ReplicateSpec};
use crate::models::streams::{IngestReading, IngestStatusEvent};
#[derive(Debug, Clone)]
pub struct StreamDescriptor {
pub source_key: String,
pub source_name: String,
pub source_path: String,
pub metadata: serde_json::Value,
pub measurement_type: Option<String>,
pub sensor_id: Option<Uuid>,
pub replicates: Option<ReplicateSpec>,
pub decimal_places: Option<i16>,
}
#[derive(Debug, Clone)]
pub struct StreamFetchRequest {
pub stream_id: Uuid,
pub source_key: String,
pub since: Option<DateTime<Utc>>,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct SourceWindow {
pub from: DateTime<Utc>,
pub to: DateTime<Utc>,
pub source_rows_read: u64,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub dropped_times: Vec<DateTime<Utc>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub content_digest: Option<String>,
}
#[derive(Debug)]
pub struct StreamReadings {
pub stream_id: Uuid,
pub source_key: String,
pub readings: Vec<IngestReading>,
pub audits: Vec<GroupAudit>,
pub collection: bool,
pub window: Option<SourceWindow>,
pub annotations: Vec<AnnotationUpsert>,
}
impl StreamReadings {
pub fn new(stream_id: Uuid, source_key: String, readings: Vec<IngestReading>) -> Self {
Self {
stream_id,
source_key,
readings,
audits: Vec::new(),
collection: false,
window: None,
annotations: Vec::new(),
}
}
}
#[derive(Debug)]
pub struct StreamStatusEvents {
pub stream_id: Uuid,
pub source_key: String,
pub events: Vec<IngestStatusEvent>,
}