mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-13 01:41:59 -04:00
Fix clippy warnings, and an actual bug with FanControl::try_from<u32>
This commit is contained in:
parent
9d7ee926f4
commit
b962bbf548
6 changed files with 21 additions and 21 deletions
|
@ -168,7 +168,7 @@ async fn main() -> Result<()> {
|
||||||
let mut log_receiver = LogReceiver::new(connection.clone()).await?;
|
let mut log_receiver = LogReceiver::new(connection.clone()).await?;
|
||||||
let remote_logger = LogLayer::new(&log_receiver).await;
|
let remote_logger = LogLayer::new(&log_receiver).await;
|
||||||
let subscriber = subscriber.with(remote_logger);
|
let subscriber = subscriber.with(remote_logger);
|
||||||
let _guard = tracing::subscriber::set_global_default(subscriber)?;
|
tracing::subscriber::set_global_default(subscriber)?;
|
||||||
|
|
||||||
let mut sigterm = signal(SignalKind::terminate())?;
|
let mut sigterm = signal(SignalKind::terminate())?;
|
||||||
let mut sigquit = signal(SignalKind::quit())?;
|
let mut sigquit = signal(SignalKind::quit())?;
|
||||||
|
|
|
@ -36,16 +36,16 @@ enum PrepareFactoryReset {
|
||||||
#[derive(PartialEq, Debug, Copy, Clone)]
|
#[derive(PartialEq, Debug, Copy, Clone)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
enum FanControl {
|
enum FanControl {
|
||||||
BIOS = 0,
|
Bios = 0,
|
||||||
OS = 1,
|
Os = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<u32> for FanControl {
|
impl TryFrom<u32> for FanControl {
|
||||||
type Error = &'static str;
|
type Error = &'static str;
|
||||||
fn try_from(v: u32) -> Result<Self, Self::Error> {
|
fn try_from(v: u32) -> Result<Self, Self::Error> {
|
||||||
match v {
|
match v {
|
||||||
x if x == FanControl::BIOS as u32 => Ok(FanControl::BIOS),
|
x if x == FanControl::Bios as u32 => Ok(FanControl::Bios),
|
||||||
x if x == FanControl::OS as u32 => Ok(FanControl::BIOS),
|
x if x == FanControl::Os as u32 => Ok(FanControl::Os),
|
||||||
_ => Err("No enum match for value {v}"),
|
_ => Err("No enum match for value {v}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,8 @@ impl TryFrom<u32> for FanControl {
|
||||||
impl fmt::Display for FanControl {
|
impl fmt::Display for FanControl {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
FanControl::BIOS => write!(f, "BIOS"),
|
FanControl::Bios => write!(f, "BIOS"),
|
||||||
FanControl::OS => write!(f, "OS"),
|
FanControl::Os => write!(f, "OS"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,8 +138,8 @@ impl SteamOSManager {
|
||||||
.await
|
.await
|
||||||
.map_err(anyhow_to_zbus_fdo)?;
|
.map_err(anyhow_to_zbus_fdo)?;
|
||||||
Ok(match active {
|
Ok(match active {
|
||||||
true => FanControl::OS as u32,
|
true => FanControl::Os as u32,
|
||||||
false => FanControl::BIOS as u32,
|
false => FanControl::Bios as u32,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,8 +155,8 @@ impl SteamOSManager {
|
||||||
.await
|
.await
|
||||||
.map_err(anyhow_to_zbus)?;
|
.map_err(anyhow_to_zbus)?;
|
||||||
match state {
|
match state {
|
||||||
FanControl::OS => jupiter_fan_control.start().await,
|
FanControl::Os => jupiter_fan_control.start().await,
|
||||||
FanControl::BIOS => jupiter_fan_control.stop().await,
|
FanControl::Bios => jupiter_fan_control.stop().await,
|
||||||
}
|
}
|
||||||
.map_err(anyhow_to_zbus)
|
.map_err(anyhow_to_zbus)
|
||||||
}
|
}
|
||||||
|
@ -336,7 +336,7 @@ impl SteamOSManager {
|
||||||
// doing things on 0 or 1 for now
|
// doing things on 0 or 1 for now
|
||||||
// Return false on error
|
// Return false on error
|
||||||
match get_wifi_backend().await {
|
match get_wifi_backend().await {
|
||||||
Ok(WifiBackend::IWD) => (),
|
Ok(WifiBackend::Iwd) => (),
|
||||||
Ok(backend) => {
|
Ok(backend) => {
|
||||||
return Err(zbus::fdo::Error::Failed(format!(
|
return Err(zbus::fdo::Error::Failed(format!(
|
||||||
"Setting wifi debug mode not supported when backend is {backend}",
|
"Setting wifi debug mode not supported when backend is {backend}",
|
||||||
|
|
|
@ -80,7 +80,7 @@ pub async fn get_gpu_performance_level() -> Result<GPUPerformanceLevel> {
|
||||||
.await
|
.await
|
||||||
.inspect_err(|message| error!("Error opening sysfs file for reading: {message}"))?;
|
.inspect_err(|message| error!("Error opening sysfs file for reading: {message}"))?;
|
||||||
|
|
||||||
GPUPerformanceLevel::from_str(level.trim().as_ref())
|
GPUPerformanceLevel::from_str(level.trim())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn set_gpu_performance_level(level: GPUPerformanceLevel) -> Result<()> {
|
pub async fn set_gpu_performance_level(level: GPUPerformanceLevel) -> Result<()> {
|
||||||
|
|
|
@ -44,7 +44,7 @@ impl Ftrace {
|
||||||
pub async fn init(connection: Connection) -> Result<Ftrace> {
|
pub async fn init(connection: Connection) -> Result<Ftrace> {
|
||||||
let path = Self::base();
|
let path = Self::base();
|
||||||
fs::create_dir_all(&path).await?;
|
fs::create_dir_all(&path).await?;
|
||||||
setup_traces(&path.as_path()).await?;
|
setup_traces(path.as_path()).await?;
|
||||||
let file = pipe::OpenOptions::new()
|
let file = pipe::OpenOptions::new()
|
||||||
.unchecked(true) // Thanks tracefs for making trace_pipe a "regular" file
|
.unchecked(true) // Thanks tracefs for making trace_pipe a "regular" file
|
||||||
.open_receiver(path.join("trace_pipe"))?;
|
.open_receiver(path.join("trace_pipe"))?;
|
||||||
|
|
|
@ -37,7 +37,7 @@ pub struct SystemdUnit<'dbus> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn daemon_reload(connection: &Connection) -> Result<()> {
|
pub async fn daemon_reload(connection: &Connection) -> Result<()> {
|
||||||
let proxy = SystemdManagerProxy::new(&connection).await?;
|
let proxy = SystemdManagerProxy::new(connection).await?;
|
||||||
proxy.reload().await?;
|
proxy.reload().await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
12
src/wifi.rs
12
src/wifi.rs
|
@ -49,7 +49,7 @@ pub enum WifiPowerManagement {
|
||||||
#[derive(PartialEq, Debug, Copy, Clone)]
|
#[derive(PartialEq, Debug, Copy, Clone)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
pub enum WifiBackend {
|
pub enum WifiBackend {
|
||||||
IWD = 0,
|
Iwd = 0,
|
||||||
WPASupplicant = 1,
|
WPASupplicant = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ impl TryFrom<u32> for WifiBackend {
|
||||||
type Error = &'static str;
|
type Error = &'static str;
|
||||||
fn try_from(v: u32) -> Result<Self, Self::Error> {
|
fn try_from(v: u32) -> Result<Self, Self::Error> {
|
||||||
match v {
|
match v {
|
||||||
x if x == WifiBackend::IWD as u32 => Ok(WifiBackend::IWD),
|
x if x == WifiBackend::Iwd as u32 => Ok(WifiBackend::Iwd),
|
||||||
x if x == WifiBackend::WPASupplicant as u32 => Ok(WifiBackend::WPASupplicant),
|
x if x == WifiBackend::WPASupplicant as u32 => Ok(WifiBackend::WPASupplicant),
|
||||||
_ => Err("No enum match for WifiBackend value {v}"),
|
_ => Err("No enum match for WifiBackend value {v}"),
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ impl FromStr for WifiBackend {
|
||||||
type Err = Error;
|
type Err = Error;
|
||||||
fn from_str(input: &str) -> Result<WifiBackend, Self::Err> {
|
fn from_str(input: &str) -> Result<WifiBackend, Self::Err> {
|
||||||
Ok(match input {
|
Ok(match input {
|
||||||
"iwd" => WifiBackend::IWD,
|
"iwd" => WifiBackend::Iwd,
|
||||||
"wpa_supplicant" => WifiBackend::WPASupplicant,
|
"wpa_supplicant" => WifiBackend::WPASupplicant,
|
||||||
_ => bail!("Unknown backend"),
|
_ => bail!("Unknown backend"),
|
||||||
})
|
})
|
||||||
|
@ -118,7 +118,7 @@ impl FromStr for WifiBackend {
|
||||||
impl fmt::Display for WifiBackend {
|
impl fmt::Display for WifiBackend {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
WifiBackend::IWD => write!(f, "iwd"),
|
WifiBackend::Iwd => write!(f, "iwd"),
|
||||||
WifiBackend::WPASupplicant => write!(f, "wpa_supplicant"),
|
WifiBackend::WPASupplicant => write!(f, "wpa_supplicant"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ mod test {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_wifi_backend_to_string() {
|
async fn test_wifi_backend_to_string() {
|
||||||
assert_eq!(WifiBackend::IWD.to_string(), "iwd");
|
assert_eq!(WifiBackend::Iwd.to_string(), "iwd");
|
||||||
assert_eq!(WifiBackend::WPASupplicant.to_string(), "wpa_supplicant");
|
assert_eq!(WifiBackend::WPASupplicant.to_string(), "wpa_supplicant");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ mod test {
|
||||||
write(path(WIFI_BACKEND_PATH), "[device]\nwifi.backend=iwd\n")
|
write(path(WIFI_BACKEND_PATH), "[device]\nwifi.backend=iwd\n")
|
||||||
.await
|
.await
|
||||||
.expect("write");
|
.expect("write");
|
||||||
assert_eq!(get_wifi_backend().await.unwrap(), WifiBackend::IWD);
|
assert_eq!(get_wifi_backend().await.unwrap(), WifiBackend::Iwd);
|
||||||
|
|
||||||
write(
|
write(
|
||||||
path(WIFI_BACKEND_PATH),
|
path(WIFI_BACKEND_PATH),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue