1pub type Result<T> = std::result::Result<T, HardwareQueryError>;
3
4#[derive(Debug, thiserror::Error)]
6pub enum HardwareQueryError {
7 #[error("System information not available: {0}")]
9 SystemInfoUnavailable(String),
10
11 #[error("Hardware device not found: {0}")]
13 DeviceNotFound(String),
14
15 #[error("Platform not supported: {0}")]
17 PlatformNotSupported(String),
18
19 #[error("Permission denied: {0}")]
21 PermissionDenied(String),
22
23 #[error("I/O error: {0}")]
25 IoError(#[from] std::io::Error),
26
27 #[error("Serialization error: {0}")]
29 SerializationError(#[from] serde_json::Error),
30
31 #[cfg(target_os = "windows")]
33 #[error("WMI error: {0}")]
34 WMIError(#[from] wmi::WMIError),
35
36 #[error("GPU driver error: {0}")]
38 GPUDriverError(String),
39
40 #[error("Invalid hardware configuration: {0}")]
42 InvalidConfiguration(String),
43
44 #[error("Monitoring error: {0}")]
46 MonitoringError(String),
47
48 #[error("Power management error: {0}")]
50 PowerManagementError(String),
51
52 #[error("Virtualization detection error: {0}")]
54 VirtualizationError(String),
55
56 #[error("Thermal management error: {0}")]
58 ThermalError(String),
59
60 #[error("Unknown error: {0}")]
62 Unknown(String),
63}
64
65impl HardwareQueryError {
66 pub fn system_info_unavailable(msg: impl Into<String>) -> Self {
67 Self::SystemInfoUnavailable(msg.into())
68 }
69
70 pub fn device_not_found(msg: impl Into<String>) -> Self {
71 Self::DeviceNotFound(msg.into())
72 }
73
74 pub fn platform_not_supported(msg: impl Into<String>) -> Self {
75 Self::PlatformNotSupported(msg.into())
76 }
77
78 pub fn permission_denied(msg: impl Into<String>) -> Self {
79 Self::PermissionDenied(msg.into())
80 }
81
82 pub fn gpu_driver_error(msg: impl Into<String>) -> Self {
83 Self::GPUDriverError(msg.into())
84 }
85
86 pub fn invalid_configuration(msg: impl Into<String>) -> Self {
87 Self::InvalidConfiguration(msg.into())
88 }
89
90 pub fn monitoring_error(msg: impl Into<String>) -> Self {
91 Self::MonitoringError(msg.into())
92 }
93
94 pub fn power_management_error(msg: impl Into<String>) -> Self {
95 Self::PowerManagementError(msg.into())
96 }
97
98 pub fn virtualization_error(msg: impl Into<String>) -> Self {
99 Self::VirtualizationError(msg.into())
100 }
101
102 pub fn thermal_error(msg: impl Into<String>) -> Self {
103 Self::ThermalError(msg.into())
104 }
105
106 pub fn unknown(msg: impl Into<String>) -> Self {
107 Self::Unknown(msg.into())
108 }
109}