use serde::Serialize;

#[derive(Debug, Clone, Eq, PartialEq, Serialize)]
pub struct ProcessInfo {
    pub pid: u32,
    pub name: String,
    pub command: String,
    pub port: u16,
}

#[derive(Debug, Clone, Eq, PartialEq, Serialize)]
pub struct PortStatus {
    pub port: u16,
    pub occupied: bool,
    pub processes: Vec<ProcessInfo>,
}

impl PortStatus {
    pub fn new(port: u16, processes: Vec<ProcessInfo>) -> Self {
        Self {
            port,
            occupied: !processes.is_empty(),
            processes,
        }
    }
}

#[derive(Debug, Clone, Eq, PartialEq, Serialize)]
pub struct KillResult {
    pub process: ProcessInfo,
    pub success: bool,
    pub message: Option<String>,
}

#[derive(Debug, Clone, Eq, PartialEq, Serialize)]
pub struct JsonExecutionReport {
    pub statuses: Vec<PortStatus>,
    pub results: Vec<KillResult>,
}
