use serde::Serialize;
use std::collections::HashMap;
use std::option::Option;
use std::string::String;
use std::vec::Vec;
#[derive(Debug, Clone, Serialize)]
pub struct ProcessNodeExport {
pub pid: u32,
pub parent_pid: Option<u32>,
pub children: Vec<u32>,
pub exe: Option<String>,
pub cmdline: Option<String>,
pub cwd: Option<String>,
pub state: ProcessStateExport,
pub depth: u32,
}
#[derive(Debug, Clone, Copy, Serialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum ProcessStateExport {
Running,
Exited,
Killed,
}
#[derive(Debug, Clone, Serialize, Default)]
pub struct ProcessTreeExport {
pub roots: Vec<u32>,
pub nodes: HashMap<u32, ProcessNodeExport>,
pub total_count: usize,
}
#[derive(Debug, Clone, Serialize)]
pub struct KillResultExport {
pub killed: Vec<u32>,
pub failed: Vec<KillFailureExport>,
pub attempted: usize,
pub success: bool,
pub duration_ms: u64,
pub order: String,
pub mode: String,
}
#[derive(Debug, Clone, Serialize)]
pub struct KillFailureExport {
pub pid: u32,
pub error: String,
pub retries: u32,
}
#[derive(Debug, Clone, Serialize)]
pub struct EventRecordExport {
pub timestamp: String,
pub pid: u32,
pub event_type: String,
pub details: serde_json::Value,
}
impl EventRecordExport {
pub fn new(
pid: u32,
timestamp: chrono::DateTime<chrono::Utc>,
event_type: String,
details: serde_json::Value,
) -> Self {
Self {
timestamp: timestamp.to_rfc3339(),
pid,
event_type,
details,
}
}
}