mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-12 01:12:30 -04:00
power: Move GPUPerformanceLevel::to_string to Display::fmt
This commit is contained in:
parent
b2f612cd45
commit
b7b09e6c17
2 changed files with 11 additions and 10 deletions
|
@ -197,7 +197,7 @@ async fn main() -> Result<()> {
|
||||||
Commands::GetGPUPerformanceLevel => {
|
Commands::GetGPUPerformanceLevel => {
|
||||||
let level = proxy.gpu_performance_level().await?;
|
let level = proxy.gpu_performance_level().await?;
|
||||||
match GPUPerformanceLevel::try_from(level) {
|
match GPUPerformanceLevel::try_from(level) {
|
||||||
Ok(l) => println!("GPU performance level: {}", l.to_string()),
|
Ok(l) => println!("GPU performance level: {}", l),
|
||||||
Err(_) => println!("Got unknown value {level} from backend"),
|
Err(_) => println!("Got unknown value {level} from backend"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
19
src/power.rs
19
src/power.rs
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use anyhow::{bail, ensure, Error, Result};
|
use anyhow::{bail, ensure, Error, Result};
|
||||||
|
use std::fmt;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use tokio::fs::{self, File};
|
use tokio::fs::{self, File};
|
||||||
|
@ -63,15 +64,15 @@ impl FromStr for GPUPerformanceLevel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToString for GPUPerformanceLevel {
|
impl fmt::Display for GPUPerformanceLevel {
|
||||||
fn to_string(&self) -> String {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
String::from(match self {
|
match self {
|
||||||
GPUPerformanceLevel::Auto => "auto",
|
GPUPerformanceLevel::Auto => write!(f, "auto"),
|
||||||
GPUPerformanceLevel::Low => "low",
|
GPUPerformanceLevel::Low => write!(f, "low"),
|
||||||
GPUPerformanceLevel::High => "high",
|
GPUPerformanceLevel::High => write!(f, "high"),
|
||||||
GPUPerformanceLevel::Manual => "manual",
|
GPUPerformanceLevel::Manual => write!(f, "manual"),
|
||||||
GPUPerformanceLevel::ProfilePeak => "peak_performance",
|
GPUPerformanceLevel::ProfilePeak => write!(f, "peak_performance"),
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue