use inspect_rs::{Inspect, InspectCx, format_tree};
#[derive(Inspect)]
enum Status {
Idle,
Running { pid: u32, threads: usize },
Failed(String),
}
#[derive(Inspect)]
struct Service {
name: String,
status: Status,
}
fn main() {
let services = vec![
Service { name: "web".to_string(), status: Status::Running { pid: 1234, threads: 8 } },
Service { name: "worker".to_string(), status: Status::Idle },
Service {
name: "cache".to_string(),
status: Status::Failed("Connection timeout".to_string()),
},
];
let mut cx = InspectCx::new();
let inspected = services.inspect(&mut cx);
println!("{}", format_tree(&inspected));
}