1use serde::Serialize;
4use std::collections::HashMap;
5use std::string::String;
6use std::vec::Vec;
7use std::option::Option; #[derive(Debug, Clone, Serialize)]
12pub struct ProcessNodeExport {
13 pub pid: u32,
14 pub parent_pid: Option<u32>,
15 pub children: Vec<u32>,
16 pub exe: Option<String>,
17 pub cmdline: Option<String>,
18 pub cwd: Option<String>,
19 pub state: ProcessStateExport,
20 pub depth: u32,
21}
22
23#[derive(Debug, Clone, Copy, Serialize, PartialEq, Eq)]
25#[serde(rename_all = "snake_case")]
26pub enum ProcessStateExport {
27 Running,
28 Exited,
29 Killed,
30}
31
32#[derive(Debug, Clone, Serialize)]
34#[derive(Default)]
35pub struct ProcessTreeExport {
36 pub roots: Vec<u32>,
38
39 pub nodes: HashMap<u32, ProcessNodeExport>,
41
42 pub total_count: usize,
44}
45
46
47
48#[derive(Debug, Clone, Serialize)]
50pub struct KillResultExport {
51 pub killed: Vec<u32>,
53
54 pub failed: Vec<KillFailureExport>,
56
57 pub attempted: usize,
59
60 pub success: bool,
62
63 pub duration_ms: u64,
65
66 pub order: String,
68
69 pub mode: String,
71}
72
73#[derive(Debug, Clone, Serialize)]
74pub struct KillFailureExport {
75 pub pid: u32,
76 pub error: String,
77 pub retries: u32,
78}
79
80#[derive(Debug, Clone, Serialize)]
82pub struct EventRecordExport {
83 pub timestamp: String,
85
86 pub pid: u32,
88
89 pub event_type: String,
91
92 pub details: serde_json::Value,
94}
95
96impl EventRecordExport {
97 pub fn new(
101 pid: u32,
102 timestamp: chrono::DateTime<chrono::Utc>,
103 event_type: String,
104 details: serde_json::Value
105 ) -> Self {
106 Self {
107 timestamp: timestamp.to_rfc3339(),
108 pid,
109 event_type,
110 details,
111 }
112 }
113}