Struct corsairmi::PowerSupply
source · [−]pub struct PowerSupply { /* private fields */ }
Expand description
Power supply.
Implementations
sourceimpl PowerSupply
impl PowerSupply
sourcepub fn open<P: AsRef<Path>>(path: P) -> Result<PowerSupply, OpenError>
pub fn open<P: AsRef<Path>>(path: P) -> Result<PowerSupply, OpenError>
Open the power supply by file path.
Example
use corsairmi::PowerSupply;
let psu: PowerSupply = PowerSupply::open("/dev/hidraw5")?;
// call psu methods here
sourcepub const fn model(&self) -> Model
pub const fn model(&self) -> Model
Get the power supply model.
Example
use corsairmi::PowerSupply;
let psu: PowerSupply = PowerSupply::open("/dev/hidraw5")?;
// e.g. "PSU model: HX580i"
println!("PSU model: {:?}", psu.model());
sourcepub fn pc_uptime(&mut self) -> Result<Duration>
pub fn pc_uptime(&mut self) -> Result<Duration>
PC uptime.
This is the duration that the PSU has been powering your PC.
Example
use corsairmi::PowerSupply;
let mut psu: PowerSupply = PowerSupply::open("/dev/hidraw5")?;
// e.g. "PC uptime: 6935s"
println!("PC uptime: {:?}", psu.pc_uptime()?);
sourcepub fn uptime(&mut self) -> Result<Duration>
pub fn uptime(&mut self) -> Result<Duration>
Power supply uptime.
This is the duration that the PSU has been connected to AC power, regardless of whether or not your PC has been powered on.
Example
use corsairmi::PowerSupply;
let mut psu: PowerSupply = PowerSupply::open("/dev/hidraw5")?;
// e.g. "PSU uptime: 10535s"
println!("PSU uptime: {:?}", psu.uptime()?);
sourcepub fn name(&mut self) -> Result<String>
pub fn name(&mut self) -> Result<String>
Model name.
This often contains the same information as PowerSupply::model
,
but this method is more expensive to call.
Example
use corsairmi::PowerSupply;
let mut psu: PowerSupply = PowerSupply::open("/dev/hidraw5")?;
// e.g. "PSU name: HX850i"
println!("PSU name: {:?}", psu.name()?);
sourcepub fn vendor(&mut self) -> Result<String>
pub fn vendor(&mut self) -> Result<String>
Vendor name.
Example
use corsairmi::PowerSupply;
let mut psu: PowerSupply = PowerSupply::open("/dev/hidraw5")?;
// e.g. "PSU name: CORSAIR"
println!("PSU name: {:?}", psu.vendor()?);
sourcepub fn product(&mut self) -> Result<String>
pub fn product(&mut self) -> Result<String>
Product name.
This often contains the same information as PowerSupply::model
,
but this method is more expensive to call.
Example
use corsairmi::PowerSupply;
let mut psu: PowerSupply = PowerSupply::open("/dev/hidraw5")?;
// e.g. "PSU product: HX850i"
println!("PSU product: {:?}", psu.product()?);
sourcepub fn temp1(&mut self) -> Result<f32>
pub fn temp1(&mut self) -> Result<f32>
Temperature reading in Celsius.
I do not know what this is a temperature reading of.
Example
use corsairmi::PowerSupply;
let mut psu: PowerSupply = PowerSupply::open("/dev/hidraw5")?;
// e.g. "Temperature: 42.25"
println!("Temperature: {:.2}", psu.temp1()?);
sourcepub fn temp2(&mut self) -> Result<f32>
pub fn temp2(&mut self) -> Result<f32>
Temperature reading in Celsius.
I do not know what this is a temperature reading of.
Example
use corsairmi::PowerSupply;
let mut psu: PowerSupply = PowerSupply::open("/dev/hidraw5")?;
// e.g. "Temperature: 34.25"
println!("Temperature: {:.2}", psu.temp2()?);
sourcepub fn rpm(&mut self) -> Result<f32>
pub fn rpm(&mut self) -> Result<f32>
Fan rotations per minute.
Example
use corsairmi::PowerSupply;
let mut psu: PowerSupply = PowerSupply::open("/dev/hidraw5")?;
// e.g. "RPM: 0.0"
println!("RPM: {:.1}", psu.rpm()?);
sourcepub fn input_voltage(&mut self) -> Result<f32>
pub fn input_voltage(&mut self) -> Result<f32>
Input voltage in volts.
Example
use corsairmi::PowerSupply;
let mut psu: PowerSupply = PowerSupply::open("/dev/hidraw5")?;
// e.g. "Input voltage: 115.0"
println!("Input voltage: {:.1}", psu.input_voltage()?);
sourcepub fn input_power(&mut self) -> Result<f32>
pub fn input_power(&mut self) -> Result<f32>
Input power in watts.
Example
use corsairmi::PowerSupply;
let mut psu: PowerSupply = PowerSupply::open("/dev/hidraw5")?;
// e.g. "Input power: 18.0"
println!("Input power: {:.1}", psu.input_power()?);
sourcepub fn input_current(&mut self) -> Result<f32>
pub fn input_current(&mut self) -> Result<f32>
Input current in amps.
This is derived from the input power and input voltage.
Example
use corsairmi::PowerSupply;
let mut psu: PowerSupply = PowerSupply::open("/dev/hidraw5")?;
// e.g. "Input current: 0.16"
println!("Input current: {:.2}", psu.input_current()?);
sourcepub fn output_select(&mut self, rail: Rail) -> Result<()>
pub fn output_select(&mut self, rail: Rail) -> Result<()>
Select the output rail to read from.
This should be called before calling PowerSupply::output_voltage
,
PowerSupply::output_current
, or PowerSupply::output_power
.
Example
use corsairmi::{PowerSupply, Rail, RAILS};
let mut psu: PowerSupply = PowerSupply::open("/dev/hidraw5")?;
for rail in RAILS.iter() {
psu.output_select(*rail)?;
println!("{} output voltage: {}V", rail, psu.output_voltage()?);
println!("{} output current: {}A", rail, psu.output_current()?);
println!("{} output power: {}W", rail, psu.output_power()?);
}
sourcepub fn output_voltage(&mut self) -> Result<f32>
pub fn output_voltage(&mut self) -> Result<f32>
Get the output voltage in volts.
Call PowerSupply::output_select
to select the rail to read from.
Example
use corsairmi::{PowerSupply, Rail};
let mut psu: PowerSupply = PowerSupply::open("/dev/hidraw5")?;
psu.output_select(Rail::Rail12v)?;
println!("12V rail output voltage: {}V", psu.output_voltage()?);
sourcepub fn output_current(&mut self) -> Result<f32>
pub fn output_current(&mut self) -> Result<f32>
Get the output current in amps.
Call PowerSupply::output_select
to select the rail to read from.
Example
use corsairmi::{PowerSupply, Rail};
let mut psu: PowerSupply = PowerSupply::open("/dev/hidraw5")?;
psu.output_select(Rail::Rail12v)?;
println!("12V rail output current: {}A", psu.output_current()?);
sourcepub fn output_power(&mut self) -> Result<f32>
pub fn output_power(&mut self) -> Result<f32>
Get the output power in watts.
Call PowerSupply::output_select
to select the rail to read from.
Example
use corsairmi::{PowerSupply, Rail};
let mut psu: PowerSupply = PowerSupply::open("/dev/hidraw5")?;
psu.output_select(Rail::Rail12v)?;
println!("12V rail output power: {}W", psu.output_power()?);
Trait Implementations
sourceimpl Debug for PowerSupply
impl Debug for PowerSupply
sourceimpl From<PowerSupply> for PowerSupply
Available on crate feature tokio
only.
impl From<PowerSupply> for PowerSupply
tokio
only.