Skip to content

Commit

Permalink
Correcting rustfmt formatting on netbsd/device.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
naguam committed May 3, 2024
1 parent 7e89040 commit 3683adc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/platform/netbsd/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ impl<'a> EnvSysDevice<'a> {
// Read that in https://github.com/NetBSD/src/blob/trunk/sys/dev/acpi/acpi_bat.c line 555.
status = attr_res.get_rstring("state")? == "invalid";
}
Ok("charging") => data.charging = Self::validate(attr_res)?.get_ri64("cur-value")?,
Ok("charging") => {
data.charging = Self::validate(attr_res)?.get_ri64("cur-value")?
}
Ok(_) => continue,
Err(e) => match attr_res.get_rdict("device-properties") {
Ok(_) => continue,
Expand Down Expand Up @@ -128,7 +130,9 @@ pub struct SysMonDevice {
impl SysMonDevice {
// data.name should match the SysMonDevice object.name already
pub fn new(data: EnvSysDevice) -> Result<Self> {
let mut bat = Self { ..Default::default() };
let mut bat = Self {
..Default::default()
};

match bat.refresh(data) {
Ok(_) => Ok(bat),
Expand All @@ -148,7 +152,8 @@ impl SysMonDevice {
"Ampere hour" => {
self.energy = microampere_hour!(data.energy) * design_voltage;
self.energy_full = microampere_hour!(data.energy_full) * design_voltage;
self.energy_full_design = microampere_hour!(data.energy_full_design) * design_voltage;
self.energy_full_design =
microampere_hour!(data.energy_full_design) * design_voltage;
}
"Watt hour" => {
self.energy = microwatt_hour!(data.energy);
Expand Down
2 changes: 1 addition & 1 deletion src/platform/netbsd/sysmon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn get_system_envsys_plist() -> Result<plist::Dictionary, Error> {
})?;

unsafe {
// The netbsd libprog says ioctl returned mmap'ed memory that must be munmap'ed.
// The netbsd libprop says ioctl returned mmap'ed memory that must be munmap'ed.
// https://www.unitedbsd.com/d/486-querying-battery-information-wo-envstat/4
// https://github.com/NetBSD/src/blob/trunk/common/lib/libprop/prop_kern.c
// Also unwrap is fine as we already check for non_null above.
Expand Down

0 comments on commit 3683adc

Please sign in to comment.