modulized everthing
This commit is contained in:
35
WatcherAgent/src/hardware/mod.rs
Normal file
35
WatcherAgent/src/hardware/mod.rs
Normal 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?,
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user