cargo fmt

This commit is contained in:
Henry Schimke
2023-02-04 13:21:27 -06:00
parent d5b2557da5
commit 5222bb25b7
2 changed files with 38 additions and 5 deletions

View File

@@ -422,3 +422,31 @@ pub fn match_single_do_co_mo_prefixed_field(
) -> Option<String> { ) -> Option<String> {
matchSinglePrefixedField(prefix, raw_text, ';', trim) matchSinglePrefixedField(prefix, raw_text, ';', trim)
} }
#[cfg(test)]
mod tests {
use crate::{
client::result::{ParsedClientResult, TextParsedRXingResult},
RXingResult,
};
use super::parse_result_with_parser;
#[test]
fn test_single_parser() {
let result: RXingResult = RXingResult::new(
"text",
vec![12, 23, 54, 23],
Vec::new(),
crate::BarcodeFormat::EAN_13,
);
let p_res = parse_result_with_parser(&result, |_| {
Some(ParsedClientResult::TextResult(TextParsedRXingResult::new(
String::from("parsed with parser"),
String::from("en/us"),
)))
})
.unwrap();
assert_eq!(p_res.to_string(), "parsed with parser");
}
}

View File

@@ -51,11 +51,13 @@ pub fn parse(theRXingResult: &crate::RXingResult) -> Option<super::ParsedClientR
return None; return None;
} }
let rawText = rawText_unstripped[WIFI_TEST.len()..].to_owned(); let rawText = rawText_unstripped[WIFI_TEST.len()..].to_owned();
let ssid = ResultParser::matchSinglePrefixedField("S:", &rawText, ';', false).unwrap_or_default(); let ssid =
ResultParser::matchSinglePrefixedField("S:", &rawText, ';', false).unwrap_or_default();
if ssid.is_empty() { if ssid.is_empty() {
return None; return None;
} }
let pass = ResultParser::matchSinglePrefixedField("P:", &rawText, ';', false).unwrap_or_default(); let pass =
ResultParser::matchSinglePrefixedField("P:", &rawText, ';', false).unwrap_or_default();
let n_type = let n_type =
if let Some(nt) = ResultParser::matchSinglePrefixedField("T:", &rawText, ';', false) { if let Some(nt) = ResultParser::matchSinglePrefixedField("T:", &rawText, ';', false) {
nt nt
@@ -82,9 +84,12 @@ pub fn parse(theRXingResult: &crate::RXingResult) -> Option<super::ParsedClientR
String::default() String::default()
}; };
let identity = ResultParser::matchSinglePrefixedField("I:", &rawText, ';', false).unwrap_or_default(); let identity =
let anonymousIdentity = ResultParser::matchSinglePrefixedField("A:", &rawText, ';', false).unwrap_or_default(); ResultParser::matchSinglePrefixedField("I:", &rawText, ';', false).unwrap_or_default();
let eapMethod = ResultParser::matchSinglePrefixedField("E:", &rawText, ';', false).unwrap_or_default(); let anonymousIdentity =
ResultParser::matchSinglePrefixedField("A:", &rawText, ';', false).unwrap_or_default();
let eapMethod =
ResultParser::matchSinglePrefixedField("E:", &rawText, ';', false).unwrap_or_default();
Some(ParsedClientResult::WiFiResult( Some(ParsedClientResult::WiFiResult(
WifiParsedRXingResult::with_details( WifiParsedRXingResult::with_details(