hw/
wmic.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use e_utils::AnyResult;
use serde::Deserialize;
#[derive(Debug, Deserialize)]
pub struct Hardware<T> {
    /// Combination of make and model (e.g., "Intel Core 2 Duo E8400")
    pub Name: String,
    /// Unique identifier for this hardware (e.g., "/intelcpu/0")
    pub Identifier: String,
    #[serde(rename = "HardwareType")]
    pub _HardwareType: String,
    /// Type of hardware
    #[serde(skip)]
    pub HardwareType: T,
    /// Identifier of parent hardware, empty string if none
    pub Parent: String,
}

/// 统一的硬件监控接口
pub trait HardwareMonitor: Sized {
    const CON_QUERY: &'static str;
    const HW_QUERY: &'static str;
    const SENSOR_QUERY: &'static str;
    type HWType;
    type SensorType;
    fn new() -> AnyResult<Self>;
    fn test(timeout: u64) -> AnyResult<()>;
}