Skip to main content

gent_daemon/messages/
stats.rs

1//! Cumulative counters on a physical carrier. Names come from the local directory.
2use serde::{Deserialize, Serialize};
3use uuid::Uuid;
4
5pub(crate) const PAGE_ROWS: usize = 256;
6pub(crate) const MAX_ROWS: usize = 65_536;
7
8/// The random token also distinguishes revision numbers reused after restore.
9#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
10pub struct Mark(pub i64, pub String);
11
12#[derive(Debug, Serialize, Deserialize)]
13#[serde(deny_unknown_fields)]
14pub struct Finish {
15    pub head: Mark,
16    pub as_of: i64,
17    pub started: i64,
18    pub ordinary: u64,
19    pub goals: u64,
20}
21
22/// [chat UUID, accepted sends, UTF-8 text bytes, attachment bytes].
23#[derive(Debug, Serialize, Deserialize)]
24pub struct Counts(pub Uuid, pub u64, pub u64, pub u64);
25
26#[derive(Serialize, Deserialize)]
27#[serde(tag = "op", rename_all = "snake_case", deny_unknown_fields)]
28pub enum Exchange {
29    Hello,
30    Read {
31        round: Uuid,
32        base: Option<Mark>,
33    },
34    Page {
35        round: Uuid,
36        page: usize,
37        full: bool,
38        rows: Vec<Counts>,
39        #[serde(default, skip_serializing_if = "Option::is_none")]
40        finish: Option<Finish>,
41    },
42}