use serde::{Deserialize, Serialize};
pub const PREFIX: &str = "/api/daemon";
pub mod route {
pub const INFO: &str = "/api/daemon/info";
pub const RESOLVE: &str = "/api/daemon/resolve";
pub const SHUTDOWN: &str = "/api/daemon/shutdown";
pub const CONTROL_HEADER: &str = "x-wsb-machine-control";
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ResolveRequest {
pub cwd: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct WorktreeInfo {
pub id: String,
pub project: Option<String>,
pub name: String,
pub root: String,
pub workspace: Option<String>,
pub no_continuity: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Info {
pub version: String,
pub pid: u32,
pub http_address: std::net::IpAddr,
pub http_port: u16,
pub machine_id: String,
pub machine_name: String,
pub peer_address: std::net::IpAddr,
pub peer_port: u16,
pub peer_refused: Option<String>,
pub worktrees: Vec<WorktreeInfo>,
}
impl Info {
pub fn worktree(&self, id: &str) -> Option<&WorktreeInfo> {
self.worktrees.iter().find(|worktree| worktree.id == id)
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ApiError {
pub error: String,
}