openbutler_protocol/runtime/status.rs
1//! Control-plane status shapes.
2
3use serde::{Deserialize, Serialize};
4
5use crate::screen::ScreenLine;
6use crate::util::{de_trio_option, trio_absent};
7
8/// Answer to a `status` request on a current host (TS `DaemonStatus`).
9///
10/// Field semantics worth keeping:
11/// - `unresponsive`: the pid is alive but IPC is dead — counts are unknown,
12/// they are *not* zero.
13/// - `entry`: the host's entry script (source or bundle) for vintage checks.
14/// - `build_id`: the running host's build identity (its own version). It is
15/// informational: clients compare protocol versions, never these strings,
16/// and *absent* means an older host that did not report one (see
17/// [`crate::util::de_trio_option`]).
18#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
19#[serde(rename_all = "camelCase")]
20pub struct DaemonStatus {
21 pub pid: u32,
22 pub started_at: String,
23 pub connected_clients: u32,
24 #[serde(default, skip_serializing_if = "Option::is_none")]
25 pub schedules: Option<u32>,
26 /// Present only as `true`; counts are unknown in this state.
27 #[serde(default, skip_serializing_if = "Option::is_none")]
28 pub unresponsive: Option<bool>,
29 #[serde(default, skip_serializing_if = "Option::is_none")]
30 pub entry: Option<String>,
31 #[serde(
32 default,
33 deserialize_with = "de_trio_option",
34 skip_serializing_if = "trio_absent"
35 )]
36 pub build_id: Option<Option<String>>,
37 /// The status screen, composed by the host. Defaulted and skipped while
38 /// empty so a host that predates the field still round-trips its own
39 /// shape; a client prints it and decides nothing.
40 #[serde(default, skip_serializing_if = "Vec::is_empty")]
41 pub lines: Vec<ScreenLine>,
42}