hardware_query/
lib.rs

1//! # Hardware Query
2//!
3//! A cross-platform Rust library for querying detailed system hardware information.
4//! Provides a unified interface to access CPU, GPU, memory, disk, network, and other
5//! hardware specifications across Windows, Linux, and macOS.
6//!
7//! ## Architecture
8//!
9//! This library uses a modular architecture:
10//!
11//! - Core modules (`cpu`, `gpu`, `memory`, etc.) provide platform-agnostic interfaces
12//! - Platform-specific implementations in the `platform` module handle OS-specific detection
13//! - Features flags enable optional vendor-specific hardware detection
14//!
15//! ## Platform Support
16//!
17//! * **Windows**: Uses Windows Management Instrumentation (WMI) and native Windows APIs
18//! * **Linux**: Utilizes `/proc`, `/sys` filesystems and platform-specific commands
19//! * **macOS**: Leverages Core Foundation, IOKit and system commands
20//!
21//! ## Performance Considerations
22//!
23//! Hardware detection operations can be relatively expensive, especially on first run.
24//! Consider caching the results when appropriate rather than querying repeatedly.
25//!
26//! ## Thread Safety
27//!
28//! All public types in this library are `Send` and `Sync` unless explicitly documented otherwise.
29//! The library is designed to be used safely in multithreaded environments.
30//!
31//! ## Features
32//!
33//! - Cross-platform hardware detection (Windows, Linux, macOS)
34//! - Detailed CPU information (cores, threads, cache, features)
35//! - GPU detection and capabilities (CUDA, ROCm, DirectML support)
36//! - Memory configuration and status
37//! - Storage device enumeration and properties
38//! - Network interface detection and capabilities
39//! - Hardware acceleration support detection
40//! - Battery status and health monitoring
41//! - Thermal sensors and fan control (where available)
42//! - PCI/USB device enumeration
43//! - Serializable hardware information
44//!
45//! ## Example
46//!
47//! ```rust
48//! use hardware_query::HardwareInfo;
49//!
50//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
51//! // Get complete system information
52//! let hw_info = HardwareInfo::query()?;
53//!
54//! // Access CPU information
55//! let cpu = hw_info.cpu();
56//! println!("CPU: {} {} with {} cores, {} threads",
57//!     cpu.vendor(),
58//!     cpu.model_name(),
59//!     cpu.physical_cores(),
60//!     cpu.logical_cores()
61//! );
62//!
63//! // Check for specific CPU features
64//! if cpu.has_feature("avx2") {
65//!     println!("CPU supports AVX2 instructions");
66//! }
67//!
68//! // Get GPU information
69//! for (i, gpu) in hw_info.gpus().iter().enumerate() {
70//!     println!("GPU {}: {} {} with {} GB VRAM",
71//!         i + 1,
72//!         gpu.vendor(),
73//!         gpu.model_name(),
74//!         gpu.memory_gb()
75//!     );
76//! }
77//!
78//! // Check specialized hardware
79//! if !hw_info.npus().is_empty() {
80//!     println!("NPUs detected: {} units", hw_info.npus().len());
81//! }
82//!
83//! if !hw_info.tpus().is_empty() {
84//!     println!("TPUs detected: {} units", hw_info.tpus().len());
85//! }
86//!
87//! // Check ARM-specific hardware (Raspberry Pi, Jetson, etc.)
88//! if let Some(arm) = hw_info.arm_hardware() {
89//!     println!("ARM System: {}", arm.system_type);
90//! }
91//!
92//! // Check FPGA hardware
93//! if !hw_info.fpgas().is_empty() {
94//!     println!("FPGAs detected: {} units", hw_info.fpgas().len());
95//! }
96//!
97//! // Get system summary
98//! let summary = hw_info.summary();
99//! println!("System Summary:\n{}", summary);
100//! # Ok(())
101//! # }
102//! ```
103
104mod battery;
105mod cpu;
106mod error;
107mod gpu;
108mod hardware_info;
109mod memory;
110mod network;
111mod npu;
112mod pci;
113pub mod platform;
114mod storage;
115mod thermal;
116mod tpu;
117mod usb;
118mod arm;
119mod fpga;
120mod power;
121mod virtualization;
122
123#[cfg(feature = "monitoring")]
124mod monitoring;
125
126// Simplified API modules
127pub mod simple;
128pub mod builder;
129pub mod presets;
130
131pub use battery::{BatteryInfo, BatteryStatus};
132pub use cpu::{CPUFeature, CPUInfo, CPUVendor};
133pub use error::{HardwareQueryError, Result};
134pub use gpu::{GPUInfo, GPUType, GPUVendor};
135pub use hardware_info::HardwareInfo;
136pub use memory::{MemoryInfo, MemoryType};
137pub use network::{NetworkInfo, NetworkType};
138pub use npu::{NPUInfo, NPUVendor, NPUType, NPUArchitecture};
139pub use pci::PCIDevice;
140pub use storage::{StorageInfo, StorageType};
141pub use thermal::{FanInfo, ThermalInfo, ThermalSensor, ThrottlingPrediction, CoolingRecommendation, ThrottlingSeverity};
142pub use tpu::{TPUInfo, TPUVendor, TPUArchitecture, TPUConnectionType};
143pub use usb::USBDevice;
144pub use arm::{ARMHardwareInfo, ARMSystemType, PowerInfo};
145pub use fpga::{FPGAInfo, FPGAVendor, FPGAFamily, FPGAInterface};
146pub use power::{PowerProfile, PowerState, ThrottlingRisk, PowerOptimization, OptimizationCategory};
147pub use virtualization::{VirtualizationInfo, VirtualizationType, ContainerRuntime, ResourceLimits};
148
149#[cfg(feature = "monitoring")]
150pub use monitoring::{HardwareMonitor, MonitoringConfig, MonitoringEvent, MonitoringStats, MonitoringCallback};
151
152// Simplified API exports - these are the recommended entry points for most users
153pub use simple::{SystemOverview, SimpleCPU, SimpleGPU, SimpleStorage, SystemHealth, 
154                 HealthStatus, TemperatureStatus, PowerStatus};
155pub use builder::{HardwareQueryBuilder, CustomHardwareInfo};
156pub use presets::{HardwarePresets, AIHardwareAssessment, GamingHardwareAssessment, 
157                  DeveloperHardwareAssessment, ServerHardwareAssessment};