tunjukin_suhu_cpu_windows

Crates.iotunjukin_suhu_cpu_windows
lib.rstunjukin_suhu_cpu_windows
version0.1.0
created_at2025-09-26 15:22:58.561897+00
updated_at2025-09-26 15:22:58.561897+00
descriptionA simple library for reading CPU temperature on Windows systems using WMI queries
homepage
repositoryhttps://github.com/SFINXVC/tunjukin_suhu_cpu_windows
max_upload_size
id1856057
size15,262
SFINXV (SFINXVC)

documentation

https://docs.rs/tunjukin_suhu_cpu_windows

README

tunjukin_suhu_cpu_windows

Crates.io Documentation License

A simple and efficient Rust library for reading CPU temperature on Windows systems using WMI (Windows Management Instrumentation) queries.

Features

  • Simple API - Just one struct and one method to get temperature
  • Dual Temperature Units - Returns both Celsius and Fahrenheit
  • Zero Configuration - Works out of the box on Windows
  • Error Handling - Detailed error messages for troubleshooting
  • Lightweight - Minimal dependencies (only regex)
  • Well Documented - Complete documentation and examples

Requirements

  • Windows operating system
  • PowerShell available in system PATH
  • Administrator privileges may be required on some systems

Installation

Add this to your Cargo.toml:

[dependencies]
tunjukin_suhu_cpu_windows = "0.1.0"

Quick Start

use tunjukin_suhu_cpu_windows::CpuTemperature;

fn main() {
    match CpuTemperature::get() {
        Ok(temp) => {
            println!("CPU Temperature: {:.2}°C / {:.2}°F", 
                     temp.celsius, temp.fahrenheit);
        }
        Err(e) => {
            eprintln!("Error reading temperature: {}", e);
        }
    }
}

Examples

Run the included example:

cargo run --example simple

API Documentation

CpuTemperature

The main struct representing a temperature reading.

Fields

  • celsius: f64 - Temperature in degrees Celsius
  • fahrenheit: f64 - Temperature in degrees Fahrenheit

Methods

  • CpuTemperature::get() -> Result<CpuTemperature, String> - Gets the current CPU temperature

How It Works

This library uses Windows Management Instrumentation (WMI) to query thermal zone sensors through PowerShell. It:

  1. Executes a PowerShell command to query MSAcpi_ThermalZoneTemperature
  2. Parses the output to extract temperature values
  3. Converts from the raw format (0.1 Kelvin units) to Celsius and Fahrenheit
  4. Returns the first available temperature reading

Error Handling

The library provides detailed error messages for common issues:

  • PowerShell execution failures
  • WMI query errors
  • Temperature sensor unavailability
  • Parsing errors
  • Permission issues

Troubleshooting

If you encounter errors:

  1. "Failed to execute PowerShell" - Ensure PowerShell is installed and in PATH
  2. "WMI query failed" - Try running as administrator
  3. "No temperature data received" - Your system may not have accessible thermal sensors
  4. "No valid temperature readings found" - The thermal zone sensors may not be accessible

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under either of

at your option.

Acknowledgments

This library is designed to be a simple, reliable solution for CPU temperature monitoring on Windows systems.

Commit count: 0

cargo fmt