diff --git a/src/wifi.rs b/src/wifi.rs index 523a3a9..33af2ae 100644 --- a/src/wifi.rs +++ b/src/wifi.rs @@ -64,6 +64,17 @@ impl TryFrom for WifiDebugMode { } } +impl FromStr for WifiDebugMode { + type Err = Error; + fn from_str(input: &str) -> Result { + 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 for WifiPowerManagement { } } +impl FromStr for WifiPowerManagement { + type Err = Error; + fn from_str(input: &str) -> Result { + 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 {