1#[cfg(feature = "system")]
4impl std::fmt::Debug for crate::Cpu {
5 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6 f.debug_struct("Cpu")
7 .field("name", &self.name())
8 .field("CPU usage", &self.usage())
9 .field("frequency", &self.frequency())
10 .field("vendor ID", &self.vendor_id())
11 .field("brand", &self.brand())
12 .finish()
13 }
14}
15
16#[cfg(feature = "system")]
17impl std::fmt::Debug for crate::System {
18 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19 f.debug_struct("System")
20 .field("global CPU usage", &self.global_cpu_usage())
21 .field("load average", &Self::load_average())
22 .field("total memory", &self.total_memory())
23 .field("free memory", &self.free_memory())
24 .field("total swap", &self.total_swap())
25 .field("free swap", &self.free_swap())
26 .field("nb CPUs", &self.cpus().len())
27 .field("nb processes", &self.processes().len())
28 .finish()
29 }
30}
31
32#[cfg(feature = "system")]
33impl std::fmt::Debug for crate::Motherboard {
34 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35 f.debug_struct("Motherboard")
36 .field("name", &self.name())
37 .field("vendor_name", &self.vendor_name())
38 .field("version", &self.version())
39 .field("serial_number", &self.serial_number())
40 .field("asset_tag", &self.asset_tag())
41 .finish()
42 }
43}
44
45#[cfg(feature = "system")]
46impl std::fmt::Debug for crate::Product {
47 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
48 f.debug_struct("Product")
49 .field("name", &Self::name())
50 .field("family", &Self::family())
51 .field("serial_number", &Self::serial_number())
52 .field("stock_keeping_unit", &Self::stock_keeping_unit())
53 .field("uuid", &Self::uuid())
54 .field("version", &Self::version())
55 .field("vendor_name", &Self::vendor_name())
56 .finish()
57 }
58}
59
60#[cfg(feature = "system")]
61impl std::fmt::Debug for crate::Process {
62 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
63 let mut f = f.debug_struct("Process");
64 f.field("pid", &self.pid())
65 .field("parent", &self.parent())
66 .field("name", &self.name())
67 .field("environ", &self.environ())
68 .field("command", &self.cmd())
69 .field("executable path", &self.exe())
70 .field("current working directory", &self.cwd())
71 .field("memory usage", &self.memory())
72 .field("virtual memory usage", &self.virtual_memory())
73 .field("CPU usage", &self.cpu_usage())
74 .field("accumulated CPU time", &self.accumulated_cpu_time())
75 .field("status", &self.status())
76 .field("root", &self.root())
77 .field("disk_usage", &self.disk_usage())
78 .field("user_id", &self.user_id())
79 .field("effective_user_id", &self.effective_user_id())
80 .field("thread_kind", &self.thread_kind());
81 #[cfg(feature = "gpu")]
82 {
83 f.field("gpu_usage", &self.gpu_usage())
84 .field("gpu_memory", &self.gpu_memory());
85 }
86 f.finish()
87 }
88}
89
90#[cfg(feature = "disk")]
91impl std::fmt::Debug for crate::Disk {
92 fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
93 write!(
94 fmt,
95 "Disk({:?})[FS: {:?}][Type: {:?}][removable: {}][I/O: {:?}] mounted on {:?}: {}/{} B",
96 self.name(),
97 self.file_system(),
98 self.kind(),
99 if self.is_removable() { "yes" } else { "no" },
100 self.usage(),
101 self.mount_point(),
102 self.available_space(),
103 self.total_space(),
104 )
105 }
106}
107
108#[cfg(feature = "disk")]
109impl std::fmt::Debug for crate::Disks {
110 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
111 f.debug_list().entries(self.iter()).finish()
112 }
113}
114
115#[cfg(feature = "component")]
116impl std::fmt::Debug for crate::Components {
117 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
118 f.debug_list().entries(self.iter()).finish()
119 }
120}
121
122#[cfg(feature = "component")]
123impl std::fmt::Debug for crate::Component {
124 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
125 write!(f, "{} ", self.label())?;
126 if let Some(temperature) = self.temperature() {
127 write!(f, "temperature: {temperature}°C (")?;
128 } else {
129 f.write_str("temperature: unknown (")?;
130 }
131 if let Some(max) = self.max() {
132 write!(f, "max: {max}°C / ")?;
133 } else {
134 f.write_str("max: unknown / ")?;
135 }
136 if let Some(critical) = self.critical() {
137 write!(f, "critical: {critical}°C)")
138 } else {
139 f.write_str("critical: unknown)")
140 }
141 }
142}
143
144#[cfg(feature = "network")]
145impl std::fmt::Debug for crate::Networks {
146 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
147 f.debug_list().entries(self.iter()).finish()
148 }
149}
150
151#[cfg(feature = "network")]
152impl std::fmt::Debug for crate::NetworkData {
153 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
154 f.debug_struct("NetworkData")
155 .field("income", &self.received())
156 .field("total income", &self.total_received())
157 .field("outcome", &self.transmitted())
158 .field("total outcome", &self.total_transmitted())
159 .field("packets income", &self.packets_received())
160 .field("total packets income", &self.total_packets_received())
161 .field("packets outcome", &self.packets_transmitted())
162 .field("total packets outcome", &self.total_packets_transmitted())
163 .field("errors income", &self.errors_on_received())
164 .field("total errors income", &self.total_errors_on_received())
165 .field("errors outcome", &self.errors_on_transmitted())
166 .field("total errors outcome", &self.total_errors_on_transmitted())
167 .field("maximum transfer unit", &self.mtu())
168 .finish()
169 }
170}
171
172#[cfg(feature = "user")]
173impl std::fmt::Debug for crate::Users {
174 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
175 f.debug_list().entries(self.iter()).finish()
176 }
177}
178
179#[cfg(feature = "user")]
180impl std::fmt::Debug for crate::User {
181 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
182 f.debug_struct("User")
183 .field("uid", &self.id())
184 .field("gid", &self.group_id())
185 .field("name", &self.name())
186 .finish()
187 }
188}
189
190#[cfg(feature = "gpu")]
191impl std::fmt::Debug for crate::Gpus {
192 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
193 f.debug_list().entries(self.iter()).finish()
194 }
195}
196
197#[cfg(feature = "gpu")]
198impl std::fmt::Debug for crate::Gpu {
199 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
200 f.debug_struct("Gpu")
201 .field("pci", &self.pci())
202 .field("vendor", &self.vendor())
203 .field("model", &self.model())
204 .field("usage", &self.usage())
205 .field("total_memory", &self.total_memory())
206 .field("used_memory", &self.used_memory())
207 .finish()
208 }
209}