use super::{ParsedRXingResult, ParsedRXingResultType, ResultParser};
#[derive(PartialEq, Eq, Hash, Debug)]
pub struct WifiParsedRXingResult {
ssid: String,
networkEncryption: String,
password: String,
hidden: bool,
identity: String,
anonymousIdentity: String,
eapMethod: String,
phase2Method: String,
}
impl ParsedRXingResult for WifiParsedRXingResult {
fn getType(&self) -> super::ParsedRXingResultType {
ParsedRXingResultType::Wifi
}
fn getDisplayRXingResult(&self) -> String {
let mut result = String::with_capacity(80);
ResultParser::maybe_append_string(&self.ssid, &mut result);
ResultParser::maybe_append_string(&self.networkEncryption, &mut result);
ResultParser::maybe_append_string(&self.password, &mut result);
ResultParser::maybe_append_string(&self.hidden.to_string(), &mut result);
result
}
}
impl WifiParsedRXingResult {
pub fn new(networkEncryption: String, ssid: String, password: String) -> Self {
Self::with_hidden(networkEncryption, ssid, password, false)
}
pub fn with_hidden(
networkEncryption: String,
ssid: String,
password: String,
hidden: bool,
) -> Self {
Self::with_details(
networkEncryption,
ssid,
password,
hidden,
String::default(),
String::default(),
String::default(),
String::default(),
)
}
#[allow(clippy::too_many_arguments)]
pub fn with_details(
networkEncryption: String,
ssid: String,
password: String,
hidden: bool,
identity: String,
anonymousIdentity: String,
eapMethod: String,
phase2Method: String,
) -> Self {
Self {
ssid,
networkEncryption,
password,
hidden,
identity,
anonymousIdentity,
eapMethod,
phase2Method,
}
}
pub fn getSsid(&self) -> &str {
&self.ssid
}
pub fn getNetworkEncryption(&self) -> &str {
&self.networkEncryption
}
pub fn getPassword(&self) -> &str {
&self.password
}
pub fn isHidden(&self) -> bool {
self.hidden
}
pub fn getIdentity(&self) -> &str {
&self.identity
}
pub fn getAnonymousIdentity(&self) -> &str {
&self.anonymousIdentity
}
pub fn getEapMethod(&self) -> &str {
&self.eapMethod
}
pub fn getPhase2Method(&self) -> &str {
&self.phase2Method
}
}