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.cpu_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 f.debug_struct("Process")
64 .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 .finish()
81 }
82}
83
84#[cfg(feature = "disk")]
85impl std::fmt::Debug for crate::Disk {
86 fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
87 write!(
88 fmt,
89 "Disk({:?})[FS: {:?}][Type: {:?}][removable: {}][I/O: {:?}] mounted on {:?}: {}/{} B",
90 self.name(),
91 self.file_system(),
92 self.kind(),
93 if self.is_removable() { "yes" } else { "no" },
94 self.usage(),
95 self.mount_point(),
96 self.available_space(),
97 self.total_space(),
98 )
99 }
100}
101
102#[cfg(feature = "disk")]
103impl std::fmt::Debug for crate::Disks {
104 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
105 f.debug_list().entries(self.iter()).finish()
106 }
107}
108
109#[cfg(feature = "component")]
110impl std::fmt::Debug for crate::Components {
111 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
112 f.debug_list().entries(self.iter()).finish()
113 }
114}
115
116#[cfg(feature = "component")]
117impl std::fmt::Debug for crate::Component {
118 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
119 write!(f, "{} ", self.label())?;
120 if let Some(temperature) = self.temperature() {
121 write!(f, "temperature: {temperature}°C (")?;
122 } else {
123 f.write_str("temperature: unknown (")?;
124 }
125 if let Some(max) = self.max() {
126 write!(f, "max: {max}°C / ")?;
127 } else {
128 f.write_str("max: unknown / ")?;
129 }
130 if let Some(critical) = self.critical() {
131 write!(f, "critical: {critical}°C)")
132 } else {
133 f.write_str("critical: unknown)")
134 }
135 }
136}
137
138#[cfg(feature = "network")]
139impl std::fmt::Debug for crate::Networks {
140 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
141 f.debug_list().entries(self.iter()).finish()
142 }
143}
144
145#[cfg(feature = "network")]
146impl std::fmt::Debug for crate::NetworkData {
147 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
148 f.debug_struct("NetworkData")
149 .field("income", &self.received())
150 .field("total income", &self.total_received())
151 .field("outcome", &self.transmitted())
152 .field("total outcome", &self.total_transmitted())
153 .field("packets income", &self.packets_received())
154 .field("total packets income", &self.total_packets_received())
155 .field("packets outcome", &self.packets_transmitted())
156 .field("total packets outcome", &self.total_packets_transmitted())
157 .field("errors income", &self.errors_on_received())
158 .field("total errors income", &self.total_errors_on_received())
159 .field("errors outcome", &self.errors_on_transmitted())
160 .field("total errors outcome", &self.total_errors_on_transmitted())
161 .field("maximum transfer unit", &self.mtu())
162 .finish()
163 }
164}
165
166#[cfg(feature = "user")]
167impl std::fmt::Debug for crate::Users {
168 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
169 f.debug_list().entries(self.iter()).finish()
170 }
171}
172
173#[cfg(feature = "user")]
174impl std::fmt::Debug for crate::User {
175 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
176 f.debug_struct("User")
177 .field("uid", &self.id())
178 .field("gid", &self.group_id())
179 .field("name", &self.name())
180 .finish()
181 }
182}