openbutler-protocol 0.0.1

The wire contract between the OpenButler daemon and its clients: frame encoding, action envelopes, and the shared state types.
Documentation
//! Control-plane status shapes.

use serde::{Deserialize, Serialize};

use crate::screen::ScreenLine;
use crate::util::{de_trio_option, trio_absent};

/// Answer to a `status` request on a current host (TS `DaemonStatus`).
///
/// Field semantics worth keeping:
/// - `unresponsive`: the pid is alive but IPC is dead — counts are unknown,
///   they are *not* zero.
/// - `entry`: the host's entry script (source or bundle) for vintage checks.
/// - `build_id`: the running host's build identity (its own version). It is
///   informational: clients compare protocol versions, never these strings,
///   and *absent* means an older host that did not report one (see
///   [`crate::util::de_trio_option`]).
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DaemonStatus {
    pub pid: u32,
    pub started_at: String,
    pub connected_clients: u32,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub schedules: Option<u32>,
    /// Present only as `true`; counts are unknown in this state.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub unresponsive: Option<bool>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub entry: Option<String>,
    #[serde(
        default,
        deserialize_with = "de_trio_option",
        skip_serializing_if = "trio_absent"
    )]
    pub build_id: Option<Option<String>>,
    /// The status screen, composed by the host. Defaulted and skipped while
    /// empty so a host that predates the field still round-trips its own
    /// shape; a client prints it and decides nothing.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub lines: Vec<ScreenLine>,
}