1pub mod error;
11pub mod devicetree;
12pub mod os;
13pub mod cpu;
14pub mod board;
15pub mod peripherals;
16
17pub use error::{HwDetectError, Result};
18pub use os::OsInfo;
19pub use cpu::CpuInfo;
20pub use board::BoardInfo;
21pub use peripherals::PeripheralInfo;
22pub use devicetree::DeviceTree;
23
24#[derive(Debug, Clone, PartialEq, Eq)]
26pub struct HardwareInfo {
27 pub board: BoardInfo,
28 pub cpu: CpuInfo,
29 pub peripherals: PeripheralInfo,
30 pub os: OsInfo,
31}
32
33impl HardwareInfo {
34 pub fn detect() -> Result<Self> {
39 Ok(HardwareInfo {
40 board: BoardInfo::detect().unwrap_or_default(),
41 cpu: CpuInfo::detect()?,
42 peripherals: PeripheralInfo::detect()?,
43 os: OsInfo::detect()?,
44 })
45 }
46}
47
48pub type Error = HwDetectError;
50
51#[cfg(test)]
52mod tests {
53 use super::*;
54
55 #[test]
57 fn smoke_test_full_detection() {
58 let result = HardwareInfo::detect();
59 assert!(result.is_ok() || result.is_err()); if let Ok(info) = result {
62 println!("Detected Hardware Info: {:#?}", info);
63 assert!(!info.os.kernel_version.is_empty());
64 assert!(info.cpu.core_count > 0);
65 } else {
66 println!("Detection failed (expected on non-Linux/minimal systems): {:?}", result.unwrap_err());
67 }
68 }
69}