mqtt_system_monitor/
status.rs1use serde::Serialize;
2use std::collections::HashMap;
3use std::fmt;
4
5#[derive(Serialize, Debug, Default)]
9pub struct StatusMessage {
10 pub available: &'static str,
11
12 pub cpu_usage: Option<f32>,
14
15 pub cpu_temp: Option<f32>,
17
18 pub memory_usage: Option<f32>,
20
21 pub network: HashMap<String, NetworkStatus>,
22}
23
24#[derive(Serialize, Debug, Default)]
26pub struct NetworkStatus {
27 pub tx: Option<f64>,
29
30 pub rx: Option<f64>,
32}
33
34impl fmt::Display for StatusMessage {
35 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
37 let Ok(str) = serde_json::to_string(&self) else {
38 return Err(fmt::Error);
39 };
40 write!(f, "{str}")
41 }
42}