mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-09 16:10:34 -04:00
wifi: Add WifiDebugMode::from_str and WifiPowerManagement::from_str
This commit is contained in:
parent
20227416e1
commit
936bdb220c
1 changed files with 22 additions and 0 deletions
22
src/wifi.rs
22
src/wifi.rs
|
@ -64,6 +64,17 @@ impl TryFrom<u32> for WifiDebugMode {
|
|||
}
|
||||
}
|
||||
|
||||
impl FromStr for WifiDebugMode {
|
||||
type Err = Error;
|
||||
fn from_str(input: &str) -> Result<WifiDebugMode, Self::Err> {
|
||||
Ok(match input {
|
||||
"enable" | "enabled" | "on" | "1" => WifiDebugMode::On,
|
||||
"disable" | "disabled" | "off" | "0" => WifiDebugMode::Off,
|
||||
v => bail!("No enum match for value {v}"),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for WifiDebugMode {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
|
@ -84,6 +95,17 @@ impl TryFrom<u32> for WifiPowerManagement {
|
|||
}
|
||||
}
|
||||
|
||||
impl FromStr for WifiPowerManagement {
|
||||
type Err = Error;
|
||||
fn from_str(input: &str) -> Result<WifiPowerManagement, Self::Err> {
|
||||
Ok(match input {
|
||||
"enable" | "enabled" | "on" | "1" => WifiPowerManagement::Enabled,
|
||||
"disable" | "disabled" | "off" | "0" => WifiPowerManagement::Disabled,
|
||||
v => bail!("No enum match for value {v}"),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for WifiPowerManagement {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue