mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Add git hooks via cargo-husky. Many many cleanups.
This commit is contained in:
@@ -19,7 +19,7 @@ pub enum ProfileError {
|
||||
|
||||
impl fmt::Display for ProfileError {
|
||||
// This trait requires `fmt` with this exact signature.
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
ProfileError::Path(path, error) => write!(f, "Path {}: {}", path, error),
|
||||
ProfileError::Read(path, error) => write!(f, "Read {}: {}", path, error),
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::error::ProfileError;
|
||||
use crate::FanCurvePU;
|
||||
|
||||
pub(crate) fn pwm_str(fan: char, index: usize) -> String {
|
||||
let mut buf = "pwm1_auto_point1_pwm".to_string();
|
||||
let mut buf = "pwm1_auto_point1_pwm".to_owned();
|
||||
unsafe {
|
||||
let tmp = buf.as_bytes_mut();
|
||||
tmp[3] = fan as u8;
|
||||
@@ -17,7 +17,7 @@ pub(crate) fn pwm_str(fan: char, index: usize) -> String {
|
||||
}
|
||||
|
||||
pub(crate) fn temp_str(fan: char, index: usize) -> String {
|
||||
let mut buf = "pwm1_auto_point1_temp".to_string();
|
||||
let mut buf = "pwm1_auto_point1_temp".to_owned();
|
||||
unsafe {
|
||||
let tmp = buf.as_bytes_mut();
|
||||
tmp[3] = fan as u8;
|
||||
@@ -146,10 +146,10 @@ impl CurveData {
|
||||
for attr in device.attributes() {
|
||||
let tmp = attr.name().to_string_lossy();
|
||||
if tmp.starts_with("pwm1") && tmp.ends_with("_temp") {
|
||||
Self::set_val_from_attr(tmp.as_ref(), device, &mut self.temp)
|
||||
Self::set_val_from_attr(tmp.as_ref(), device, &mut self.temp);
|
||||
}
|
||||
if tmp.starts_with("pwm1") && tmp.ends_with("_pwm") {
|
||||
Self::set_val_from_attr(tmp.as_ref(), device, &mut self.pwm)
|
||||
Self::set_val_from_attr(tmp.as_ref(), device, &mut self.pwm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ pub mod error;
|
||||
pub mod fan_curve_set;
|
||||
|
||||
use std::fmt::Display;
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::{Read, Write};
|
||||
use std::fs::{self, OpenOptions};
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
use error::ProfileError;
|
||||
@@ -49,18 +49,12 @@ impl Profile {
|
||||
}
|
||||
|
||||
pub fn get_active_profile() -> Result<Profile, ProfileError> {
|
||||
let mut file = OpenOptions::new().read(true).open(PLATFORM_PROFILE)?;
|
||||
|
||||
let mut buf = String::new();
|
||||
file.read_to_string(&mut buf)?;
|
||||
let buf = fs::read_to_string(PLATFORM_PROFILE)?;
|
||||
Ok(buf.as_str().into())
|
||||
}
|
||||
|
||||
pub fn get_profile_names() -> Result<Vec<Profile>, ProfileError> {
|
||||
let mut file = OpenOptions::new().read(true).open(PLATFORM_PROFILES)?;
|
||||
|
||||
let mut buf = String::new();
|
||||
file.read_to_string(&mut buf)?;
|
||||
let buf = fs::read_to_string(PLATFORM_PROFILES)?;
|
||||
Ok(buf.rsplit(' ').map(|p| p.into()).collect())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user