Skip to content

Commit

Permalink
sta: impl Display instead of ToString directly
Browse files Browse the repository at this point in the history
  • Loading branch information
lthiery committed May 22, 2024
1 parent 0fa8579 commit 47737e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/sta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ impl WifiStation {
match param {
SetNetwork::Ssid(ssid) => format!("ssid \"{ssid}\""),
SetNetwork::Psk(psk) => format!("psk \"{psk}\""),
SetNetwork::KeyMgmt(mgmt) => format!("key_mgmt {}", mgmt.to_string()),
SetNetwork::KeyMgmt(mgmt) => format!("key_mgmt {}", mgmt),
}
);
debug!("wpa_ctrl \"{cmd}\"");
Expand Down
10 changes: 6 additions & 4 deletions src/sta/types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::{error, warn, Result};
use serde::Serialize;
use std::collections::HashMap;
use std::fmt::Display;
use std::str::FromStr;
use tokio::net::UnixDatagram;

Expand Down Expand Up @@ -125,13 +126,14 @@ pub enum KeyMgmt {
IEEE8021X,
}

impl ToString for KeyMgmt {
fn to_string(&self) -> String {
match self {
impl Display for KeyMgmt {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let str = match self {
KeyMgmt::None => "NONE".to_string(),
KeyMgmt::WpaPsk => "WPA-PSK".to_string(),
KeyMgmt::WpaEap => "WPA-EAP".to_string(),
KeyMgmt::IEEE8021X => "IEEE8021X".to_string(),
}
};
write!(f, "{}", str)
}
}

0 comments on commit 47737e2

Please sign in to comment.