added commentation
This commit is contained in:
@@ -7,6 +7,27 @@ use sysinfo::{Component, Components, Disk, Disks};
|
||||
use serde::Serialize;
|
||||
|
||||
|
||||
//! # Disk Hardware Module
|
||||
//!
|
||||
//! This module provides disk information collection for WatcherAgent, including total and per-disk statistics and temperature data.
|
||||
//!
|
||||
//! ## Responsibilities
|
||||
//! - **Disk Enumeration:** Lists all physical disks and their properties.
|
||||
//! - **Usage Calculation:** Computes total and per-disk usage, available space, and usage percentage.
|
||||
//! - **Temperature Monitoring:** Associates disk components with temperature sensors if available.
|
||||
//!
|
||||
//! ## Units
|
||||
//! - All sizes are in **bytes** unless otherwise noted.
|
||||
//! - Temperatures are in **degrees Celsius (°C)**.
|
||||
//!
|
||||
/// Summary of disk statistics for the system.
|
||||
///
|
||||
/// # Fields
|
||||
/// - `total_size`: Total disk size in bytes (all disks > 100MB)
|
||||
/// - `total_used`: Total used disk space in bytes
|
||||
/// - `total_available`: Total available disk space in bytes
|
||||
/// - `total_usage`: Usage percentage (0.0–100.0)
|
||||
/// - `detailed_info`: Vector of [`DiskInfoDetailed`] for each disk
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct DiskInfo {
|
||||
pub total_size: Option<f64>,
|
||||
@@ -16,6 +37,12 @@ pub struct DiskInfo {
|
||||
pub detailed_info: Vec<DiskInfoDetailed>,
|
||||
}
|
||||
|
||||
/// Collects disk information for all detected disks, including usage and temperature.
|
||||
///
|
||||
/// This function enumerates all disks, calculates usage statistics, and attempts to associate temperature sensors with disk components.
|
||||
///
|
||||
/// # Returns
|
||||
/// * `Result<DiskInfo, Box<dyn std::error::Error + Send + Sync>>` - Disk statistics and details, or error if collection fails.
|
||||
pub async fn get_disk_info() -> Result<DiskInfo, Box<dyn std::error::Error + Send + Sync>> {
|
||||
let disks = Disks::new_with_refreshed_list();
|
||||
let mut detailed_info = Vec::new();
|
||||
|
Reference in New Issue
Block a user