modulized everthing

This commit is contained in:
2025-08-08 18:59:57 +02:00
parent f0b89a9c32
commit abfa0b6fc0
11 changed files with 690 additions and 570 deletions

View File

@@ -0,0 +1,35 @@
//use anyhow::Result;
use std::error::Error;
mod cpu;
mod disk;
mod gpu;
mod memory;
mod network;
pub use cpu::get_cpu_info;
pub use disk::get_disk_info;
pub use gpu::get_gpu_info;
pub use memory::get_memory_info;
pub use network::get_network_info;
#[derive(Debug)]
pub struct HardwareInfo {
pub cpu: cpu::CpuInfo,
pub gpu: gpu::GpuInfo,
pub memory: memory::MemoryInfo,
pub disk: disk::DiskInfo,
pub network: network::NetworkInfo,
}
impl HardwareInfo {
pub async fn collect() -> anyhow::Result<Self, Box<dyn Error>> {
Ok(Self {
cpu: get_cpu_info().await?,
gpu: get_gpu_info().await?,
memory: get_memory_info().await?,
disk: get_disk_info().await?,
network: get_network_info().await?,
})
}
}