use std::path::{Path, PathBuf};
use serde::{Deserialize, Serialize};
pub const NETWORK_DAEMON_PROTOCOL_VERSION: u32 = 1;
pub const NETWORK_DAEMON_NAME: &str = "heddle-netd";
pub const NETWORK_DAEMON_SOCKET: &str = "heddle-netd.sock";
pub fn network_daemon_endpoint_path(heddle_home: &Path) -> PathBuf {
repo::daemon::box_endpoint_path_in(heddle_home, NETWORK_DAEMON_NAME)
}
pub fn network_daemon_socket_path(heddle_home: &Path) -> PathBuf {
repo::daemon::box_state_dir_in(heddle_home).join(NETWORK_DAEMON_SOCKET)
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum NetworkDaemonRequest {
Health {},
Shutdown {},
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum NetworkDaemonResponse {
Health {
version: u32,
ok: bool,
uptime_s: u64,
node_id: String,
},
Shutdown { version: u32, ok: bool },
Error {
version: u32,
code: String,
message: String,
},
}