Expand description
§Hardware Query
The easiest way to get hardware information in Rust.
This crate provides a simple, cross-platform API for hardware detection and system monitoring. Whether you need a quick system overview or detailed hardware analysis, there’s an API tier for you.
§Quick Start (1 line of code)
Get a complete system overview with health status:
use hardware_query::SystemOverview;
let overview = SystemOverview::quick()?;
println!("{}", overview); // Formatted system summary with health status
§Domain-Specific Presets (2-3 lines)
Get assessments tailored to your use case:
use hardware_query::HardwarePresets;
// For AI/ML applications
let ai_assessment = HardwarePresets::ai_assessment()?;
println!("AI Score: {}/100", ai_assessment.ai_score);
println!("Supported Frameworks: {:?}", ai_assessment.frameworks);
// For gaming applications
let gaming_assessment = HardwarePresets::gaming_assessment()?;
println!("Gaming Score: {}/100", gaming_assessment.gaming_score);
println!("Recommended Settings: {}", gaming_assessment.recommended_settings);
// For development environments
let dev_assessment = HardwarePresets::developer_assessment()?;
println!("Build Performance: {:?}", dev_assessment.build_performance);
§Custom Queries (3-5 lines)
Build exactly the hardware query you need:
use hardware_query::HardwareQueryBuilder;
// Get basic system info
let basic_info = HardwareQueryBuilder::new()
.with_basic()
.cpu_and_memory()?;
// Get AI-focused hardware info
let ai_info = HardwareQueryBuilder::new()
.with_ai_focused()
.gpu_and_accelerators()?;
// Get everything for system monitoring
let monitoring_info = HardwareQueryBuilder::new()
.with_monitoring()
.all_hardware()?;
§Complete Hardware Analysis (Advanced)
For detailed hardware analysis and custom processing:
use hardware_query::HardwareInfo;
// Get complete system information
let hw_info = HardwareInfo::query()?;
// Access detailed CPU information
let cpu = hw_info.cpu();
println!("CPU: {} {} - {} cores, {} threads",
cpu.vendor(),
cpu.model_name(),
cpu.physical_cores(),
cpu.logical_cores()
);
// Check specific CPU features for optimization
if cpu.has_feature("avx2") && cpu.has_feature("fma") {
println!("CPU optimized for SIMD operations");
}
// Analyze GPU capabilities for AI workloads
for gpu in hw_info.gpus() {
println!("GPU: {} {} - {} GB VRAM",
gpu.vendor(), gpu.model_name(), gpu.memory_gb());
if gpu.supports_cuda() {
println!(" CUDA support available");
}
if gpu.supports_opencl() {
println!(" OpenCL support available");
}
}
// Check for specialized AI hardware
if !hw_info.npus().is_empty() {
println!("AI accelerators found: {} NPUs", hw_info.npus().len());
}
// Memory analysis for performance optimization
let memory = hw_info.memory();
println!("Memory: {} GB total, {} GB available",
memory.total_gb(),
memory.available_gb()
);
// Storage performance characteristics
for storage in hw_info.storage() {
println!("Storage: {} - {} GB ({})",
storage.model(),
storage.capacity_gb(),
if storage.is_ssd() { "SSD" } else { "HDD" }
);
}
§Monitoring and Real-time Updates
For applications that need continuous hardware monitoring:
#[cfg(feature = "monitoring")]
use hardware_query::{HardwareMonitor, MonitoringConfig};
let config = MonitoringConfig::new()
.with_cpu_monitoring(true)
.with_thermal_monitoring(true)
.with_interval_ms(1000);
let mut monitor = HardwareMonitor::new(config);
monitor.start_monitoring(|event| {
match event {
hardware_query::MonitoringEvent::TemperatureAlert { component, temp } => {
println!("Warning: {} temperature: {}°C", component, temp);
}
hardware_query::MonitoringEvent::CpuUsageHigh { usage } => {
println!("High CPU usage: {}%", usage);
}
_ => {}
}
})?;
§Feature Flags
- Default: Basic hardware detection (CPU, Memory, GPU, Storage)
monitoring
: Real-time monitoring capabilities, thermal sensors, power managementserde
: Serialization/deserialization support (automatically enabled)
§Platform Support
- Windows: Native WMI and Windows API support
- Linux: Comprehensive
/proc
,/sys
filesystem support - macOS: IOKit and system framework integration
All APIs work consistently across platforms, with graceful degradation when specific hardware isn’t available.
Re-exports§
pub use simple::SystemOverview;
pub use simple::SimpleCPU;
pub use simple::SimpleGPU;
pub use simple::SimpleStorage;
pub use simple::SystemHealth;
pub use simple::HealthStatus;
pub use simple::TemperatureStatus;
pub use simple::PowerStatus;
pub use builder::HardwareQueryBuilder;
pub use builder::CustomHardwareInfo;
pub use presets::HardwarePresets;
pub use presets::AIHardwareAssessment;
pub use presets::GamingHardwareAssessment;
pub use presets::DeveloperHardwareAssessment;
pub use presets::ServerHardwareAssessment;
Modules§
- builder
- Hardware query builder for customizable hardware information gathering
- platform
- presets
- Hardware query presets for common use cases
- simple
- Simplified hardware query interface - Start here for easy hardware detection
Structs§
- ARMHardware
Info - ARM hardware information
- Battery
Info - Battery information
- CPUInfo
- CPU information and specifications
- Container
Runtime - Container runtime information
- Cooling
Recommendation - Cooling optimization recommendation
- FPGA
Info - FPGA accelerator information
- FanInfo
- Fan information
- GPUInfo
- GPU information and specifications
- Hardware
Info - Complete system hardware information
- Hardware
Monitor - Real-time hardware monitor
- Memory
Info - System memory information
- Monitoring
Config - Hardware monitoring configuration
- Monitoring
Stats - Monitoring statistics
- NPUInfo
- NPU information structure
- Network
Info - Network interface information
- PCIDevice
- PCI device information
- Power
Info - Power consumption and thermal information
- Power
Optimization - Power optimization recommendation
- Power
Profile - Power consumption profile for the system
- Resource
Limits - Resource limits imposed by virtualization
- Storage
Info - Storage device information
- TPUInfo
- TPU information structure
- Thermal
Info - System thermal information
- Thermal
Sensor - Thermal sensor information
- Throttling
Prediction - Thermal throttling prediction
- USBDevice
- USB device information
- Virtualization
Info - Virtualization environment 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
- Monitoring
Event - Hardware monitoring event
- NPUArchitecture
- NPU architecture information
- NPUType
- NPU type classification
- NPUVendor
- NPU vendor information
- Network
Type - Network interface type
- Optimization
Category - Category of power optimization
- Power
State - Current system power state
- Storage
Type - Storage device type
- TPUArchitecture
- TPU generation and architecture
- TPUConnection
Type - TPU connection type
- TPUVendor
- TPU vendor information
- Throttling
Risk - Risk level for thermal throttling
- Throttling
Severity - Severity of thermal throttling
- Virtualization
Type - Type of virtualization environment
Traits§
- Monitoring
Callback - Hardware monitoring callback trait
Type Aliases§
- Result
- Result type for hardware query operations