feat(protocol): ServerState enum

This commit is contained in:
2026-05-25 11:21:43 +02:00
parent 1b76378b37
commit 0e49834c93
2 changed files with 35 additions and 0 deletions
+4
View File
@@ -1 +1,5 @@
//! Wire types and config schema shared between the xy daemon and CLI.
pub mod state;
pub use state::ServerState;
+31
View File
@@ -0,0 +1,31 @@
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum ServerState {
Stopped,
Starting,
Running,
Restarting,
Failed,
Stopping,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn serializes_to_kebab_case() {
assert_eq!(
serde_json::to_string(&ServerState::Restarting).unwrap(),
"\"restarting\""
);
}
#[test]
fn deserializes_from_kebab_case() {
let s: ServerState = serde_json::from_str("\"failed\"").unwrap();
assert_eq!(s, ServerState::Failed);
}
}