Expand description
§Hardware Query
A cross-platform Rust library for querying detailed system hardware information. Provides a unified interface to access CPU, GPU, memory, disk, network, and other hardware specifications across Windows, Linux, and macOS.
§Architecture
This library uses a modular architecture:
- Core modules (
cpu
,gpu
,memory
, etc.) provide platform-agnostic interfaces - Platform-specific implementations in the
platform
module handle OS-specific detection - Features flags enable optional vendor-specific hardware detection
§Platform Support
- Windows: Uses Windows Management Instrumentation (WMI) and native Windows APIs
- Linux: Utilizes
/proc
,/sys
filesystems and platform-specific commands - macOS: Leverages Core Foundation, IOKit and system commands
§Performance Considerations
Hardware detection operations can be relatively expensive, especially on first run. Consider caching the results when appropriate rather than querying repeatedly.
§Thread Safety
All public types in this library are Send
and Sync
unless explicitly documented otherwise.
The library is designed to be used safely in multithreaded environments.
§Features
- Cross-platform hardware detection (Windows, Linux, macOS)
- Detailed CPU information (cores, threads, cache, features)
- GPU detection and capabilities (CUDA, ROCm, DirectML support)
- Memory configuration and status
- Storage device enumeration and properties
- Network interface detection and capabilities
- Hardware acceleration support detection
- Battery status and health monitoring
- Thermal sensors and fan control (where available)
- PCI/USB device enumeration
- Serializable hardware information
§Example
use hardware_query::HardwareInfo;
// Get complete system information
let hw_info = HardwareInfo::query()?;
// Access CPU information
let cpu = hw_info.cpu();
println!("CPU: {} {} with {} cores, {} threads",
cpu.vendor(),
cpu.model_name(),
cpu.physical_cores(),
cpu.logical_cores()
);
// Check for specific CPU features
if cpu.has_feature("avx2") {
println!("CPU supports AVX2 instructions");
}
// Get GPU information
for (i, gpu) in hw_info.gpus().iter().enumerate() {
println!("GPU {}: {} {} with {} GB VRAM",
i + 1,
gpu.vendor(),
gpu.model_name(),
gpu.memory_gb()
);
}
// Check specialized hardware
if !hw_info.npus().is_empty() {
println!("NPUs detected: {} units", hw_info.npus().len());
}
if !hw_info.tpus().is_empty() {
println!("TPUs detected: {} units", hw_info.tpus().len());
}
// Check ARM-specific hardware (Raspberry Pi, Jetson, etc.)
if let Some(arm) = hw_info.arm_hardware() {
println!("ARM System: {}", arm.system_type);
}
// Check FPGA hardware
if !hw_info.fpgas().is_empty() {
println!("FPGAs detected: {} units", hw_info.fpgas().len());
}
// Get system summary
let summary = hw_info.summary();
println!("System Summary:\n{}", summary);
Modules§
Structs§
- ARMHardware
Info - ARM hardware information
- Battery
Info - Battery information
- CPUInfo
- CPU information and specifications
- FPGA
Info - FPGA accelerator information
- FanInfo
- Fan information
- GPUInfo
- GPU information and specifications
- Hardware
Info - Complete system hardware information
- Memory
Info - System memory information
- NPUInfo
- NPU information structure
- Network
Info - Network interface information
- PCIDevice
- PCI device information
- Power
Info - Power consumption and thermal information
- Storage
Info - Storage device information
- TPUInfo
- TPU information structure
- Thermal
Info - System thermal information
- Thermal
Sensor - Thermal sensor information
- USBDevice
- USB device information
Enums§
- ARMSystem
Type - ARM-based system type
- Battery
Status - Battery status
- CPUFeature
- CPU feature flags
- CPUVendor
- CPU vendor information
- FPGA
Family - FPGA family/series information
- FPGA
Interface - FPGA interface type
- FPGA
Vendor - FPGA vendor information
- GPUType
- GPU type classification
- GPUVendor
- GPU vendor information
- Hardware
Query Error - Error types that can occur during hardware querying
- Memory
Type - Memory type classification
- NPUArchitecture
- NPU architecture information
- NPUType
- NPU type classification
- NPUVendor
- NPU vendor information
- Network
Type - Network interface type
- Storage
Type - Storage device type
- TPUArchitecture
- TPU generation and architecture
- TPUConnection
Type - TPU connection type
- TPUVendor
- TPU vendor information
Type Aliases§
- Result
- Result type for hardware query operations