power: Make GPUPerformanceLevel::from_str implementation consistent with others

This commit is contained in:
Vicki Pfau 2024-05-13 16:44:39 -07:00
parent fbfb07e684
commit 20227416e1

View file

@ -5,7 +5,7 @@
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
use anyhow::{anyhow, bail, ensure, Error, Result}; use anyhow::{bail, ensure, Error, Result};
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};
@ -52,14 +52,14 @@ impl TryFrom<u32> for GPUPerformanceLevel {
impl FromStr for GPUPerformanceLevel { impl FromStr for GPUPerformanceLevel {
type Err = Error; type Err = Error;
fn from_str(input: &str) -> Result<GPUPerformanceLevel, Self::Err> { fn from_str(input: &str) -> Result<GPUPerformanceLevel, Self::Err> {
match input { Ok(match input {
"auto" => Ok(GPUPerformanceLevel::Auto), "auto" => GPUPerformanceLevel::Auto,
"low" => Ok(GPUPerformanceLevel::Low), "low" => GPUPerformanceLevel::Low,
"high" => Ok(GPUPerformanceLevel::High), "high" => GPUPerformanceLevel::High,
"manual" => Ok(GPUPerformanceLevel::Manual), "manual" => GPUPerformanceLevel::Manual,
"peak_performance" => Ok(GPUPerformanceLevel::ProfilePeak), "peak_performance" => GPUPerformanceLevel::ProfilePeak,
v => Err(anyhow!("No enum match for value {v}")), v => bail!("No enum match for value {v}"),
} })
} }
} }