To get the system CPU temperature in Rust, we need to use a crate called sys-info. This crate provides functions to retrieve system information, including CPU temperature.
First, add sys-info to your Cargo.toml file:
34 chars3 linesThen, use the sys_info::loadavg() function to retrieve the load average information, which includes the CPU temperature:
main.rs313 chars11 linesNote that the get_temperature() function returns the temperature in Celsius.
gistlibby LogSnag