msr-driver-rs 1.0.1

Minimal Rust wrapper around Windows MSR drivers (Scaphandre or WinRing0)
docs.rs failed to build msr-driver-rs-1.0.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

msr-driver-rs

Minimal Rust wrapper around Windows MSR drivers (Scaphandre or WinRing0).

Features

  • scaphandre (default): Uses the Scaphandre RAPL driver
  • winring0: Uses the WinRing0 driver

Note: Only one feature can be enabled at a time.

Using Scaphandre

To use the Scaphandre driver, execute the following:

cargo add msr-driver-rs

Using WinRing0

To use WinRing0 instead of Scaphandre, execute the following:

cargo add msr-driver-rs --no-default-features --features winring0

Usage

use msr_driver_rs::MsrDriver;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let driver = MsrDriver::new()?;
    let msr_pkg_energy_status = 0x0000_0611;
    let value = driver.read_msr(msr_pkg_energy_status, 0)?;
    println!("MSR value: {value:#x}");
    Ok(())
}

Admin operations

MsrDriver::install()?;
MsrDriver::uninstall()?;

Notes

  • Windows only.
  • new() opens the device handle. It does not install the driver.
  • install(), uninstall() and start() require Administrator privileges.
  • is_installed() can be used without admin rights.

Example

A working example is included:

cargo run --example wattseal_like

It polls the energy counter, calculates the joules consumed, and average power consumption, such as what WattSeal does.

License

Apache-2.0.