mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-10 00:20:29 -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 => {
|
||||
let level = proxy.gpu_performance_level().await?;
|
||||
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"),
|
||||
}
|
||||
}
|
||||
|
|
19
src/power.rs
19
src/power.rs
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
use anyhow::{bail, ensure, Error, Result};
|
||||
use std::fmt;
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use tokio::fs::{self, File};
|
||||
|
@ -63,15 +64,15 @@ impl FromStr for GPUPerformanceLevel {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToString for GPUPerformanceLevel {
|
||||
fn to_string(&self) -> String {
|
||||
String::from(match self {
|
||||
GPUPerformanceLevel::Auto => "auto",
|
||||
GPUPerformanceLevel::Low => "low",
|
||||
GPUPerformanceLevel::High => "high",
|
||||
GPUPerformanceLevel::Manual => "manual",
|
||||
GPUPerformanceLevel::ProfilePeak => "peak_performance",
|
||||
})
|
||||
impl fmt::Display for GPUPerformanceLevel {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
GPUPerformanceLevel::Auto => write!(f, "auto"),
|
||||
GPUPerformanceLevel::Low => write!(f, "low"),
|
||||
GPUPerformanceLevel::High => write!(f, "high"),
|
||||
GPUPerformanceLevel::Manual => write!(f, "manual"),
|
||||
GPUPerformanceLevel::ProfilePeak => write!(f, "peak_performance"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue