added commentation
This commit is contained in:
@@ -14,6 +14,23 @@ pub use memory::get_memory_info;
|
||||
pub use network::get_network_info;
|
||||
pub use network::NetworkMonitor;
|
||||
|
||||
//! # Hardware Module
|
||||
//!
|
||||
//! This module aggregates all hardware subsystems for WatcherAgent, providing unified collection and access to CPU, GPU, memory, disk, and network statistics.
|
||||
//!
|
||||
//! ## Responsibilities
|
||||
//! - **Subsystem Aggregation:** Combines all hardware modules into a single struct for easy access.
|
||||
//! - **Unified Collection:** Provides a single async method to collect all hardware metrics at once.
|
||||
//!
|
||||
/// Aggregated hardware statistics for the host system.
|
||||
///
|
||||
/// # Fields
|
||||
/// - `cpu`: CPU statistics (see [`CpuInfo`])
|
||||
/// - `gpu`: GPU statistics (see [`GpuInfo`])
|
||||
/// - `memory`: Memory statistics (see [`MemoryInfo`])
|
||||
/// - `disk`: Disk statistics (see [`DiskInfo`])
|
||||
/// - `network`: Network statistics (see [`NetworkInfo`])
|
||||
/// - `network_monitor`: Rolling monitor for network bandwidth
|
||||
#[derive(Debug)]
|
||||
pub struct HardwareInfo {
|
||||
pub cpu: cpu::CpuInfo,
|
||||
@@ -25,6 +42,10 @@ pub struct HardwareInfo {
|
||||
}
|
||||
|
||||
impl HardwareInfo {
|
||||
/// Collects all hardware statistics asynchronously.
|
||||
///
|
||||
/// # Returns
|
||||
/// * `Result<HardwareInfo, Box<dyn Error + Send + Sync>>` - Aggregated hardware statistics or error if any subsystem fails.
|
||||
pub async fn collect() -> Result<Self, Box<dyn Error + Send + Sync>> {
|
||||
let mut network_monitor = network::NetworkMonitor::new();
|
||||
Ok(Self {
|
||||
|
Reference in New Issue
Block a user