pub type Result<T> = std::result::Result<T, HardwareQueryError>;
#[derive(Debug, thiserror::Error)]
pub enum HardwareQueryError {
#[error("System information not available: {0}")]
SystemInfoUnavailable(String),
#[error("Hardware device not found: {0}")]
DeviceNotFound(String),
#[error("Platform not supported: {0}")]
PlatformNotSupported(String),
#[error("Permission denied: {0}")]
PermissionDenied(String),
#[error("I/O error: {0}")]
IoError(#[from] std::io::Error),
#[error("Serialization error: {0}")]
SerializationError(#[from] serde_json::Error),
#[cfg(target_os = "windows")]
#[error("WMI error: {0}")]
WMIError(#[from] wmi::WMIError),
#[error("GPU driver error: {0}")]
GPUDriverError(String),
#[error("Invalid hardware configuration: {0}")]
InvalidConfiguration(String),
#[error("Monitoring error: {0}")]
MonitoringError(String),
#[error("Power management error: {0}")]
PowerManagementError(String),
#[error("Virtualization detection error: {0}")]
VirtualizationError(String),
#[error("Thermal management error: {0}")]
ThermalError(String),
#[error("Unknown error: {0}")]
Unknown(String),
}
impl HardwareQueryError {
pub fn system_info_unavailable(msg: impl Into<String>) -> Self {
Self::SystemInfoUnavailable(msg.into())
}
pub fn device_not_found(msg: impl Into<String>) -> Self {
Self::DeviceNotFound(msg.into())
}
pub fn platform_not_supported(msg: impl Into<String>) -> Self {
Self::PlatformNotSupported(msg.into())
}
pub fn permission_denied(msg: impl Into<String>) -> Self {
Self::PermissionDenied(msg.into())
}
pub fn gpu_driver_error(msg: impl Into<String>) -> Self {
Self::GPUDriverError(msg.into())
}
pub fn invalid_configuration(msg: impl Into<String>) -> Self {
Self::InvalidConfiguration(msg.into())
}
pub fn monitoring_error(msg: impl Into<String>) -> Self {
Self::MonitoringError(msg.into())
}
pub fn power_management_error(msg: impl Into<String>) -> Self {
Self::PowerManagementError(msg.into())
}
pub fn virtualization_error(msg: impl Into<String>) -> Self {
Self::VirtualizationError(msg.into())
}
pub fn thermal_error(msg: impl Into<String>) -> Self {
Self::ThermalError(msg.into())
}
pub fn unknown(msg: impl Into<String>) -> Self {
Self::Unknown(msg.into())
}
}