use serde::{Deserialize, Serialize};
use crate::db::Scope;
use alloc::string::String;
use alloc::vec::Vec;
pub type Timestamp = u64;
#[derive(Debug, Serialize, Deserialize)]
#[allow(missing_docs)]
pub struct PublishRequest {
pub scope: Scope,
pub measurement: Measurement,
}
#[derive(Debug, Serialize, Deserialize)]
#[allow(missing_docs)]
pub struct Measurement {
pub name: String,
pub tags: Vec<(String, String)>,
pub fields: Vec<(String, FieldValue)>,
pub ts: Option<Timestamp>,
}
#[derive(Debug, Serialize, Deserialize)]
#[allow(missing_docs)]
pub enum FieldValue {
I64(i64),
U64(u64),
F64(f64),
String(String),
Boolean(bool),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
pub enum TsOrderBy {
TimestampAsc,
#[default]
TimestampDesc,
}
#[derive(Debug, Serialize, Deserialize)]
#[allow(missing_docs)]
pub struct FindRequest {
pub scope: Scope,
pub measurement_name: String,
pub limit: Option<usize>,
pub start: Option<Timestamp>,
pub end: Option<Timestamp>,
pub order: Option<TsOrderBy>,
}
#[derive(Debug, Serialize, Deserialize)]
#[allow(missing_docs)]
pub struct FindResponse {
pub samples: Vec<Sample>,
}
#[derive(Debug, Serialize, Deserialize)]
#[allow(missing_docs)]
pub struct Sample {
pub tags: Vec<(String, String)>,
pub fields: Vec<(String, FieldValue)>,
pub timestamp: Timestamp,
}