Skip to content

Commit

Permalink
Fix RegexParsingError when parsing device list (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
JinkeJ authored Oct 11, 2024
1 parent e37b6d4 commit 95fe89a
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions adb_client/src/models/device_long.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,13 @@ impl TryFrom<Vec<u8>> for DeviceLong {
.as_bytes()
.to_vec(),
)?)?,
usb: String::from_utf8(
groups
.name("usb1")
.or_else(|| groups.name("usb2"))
.ok_or(RustADBError::RegexParsingError)?
.as_bytes()
.to_vec(),
)?,
usb: match groups.name("usb1") {
None => match groups.name("usb2") {
None => "Unk".to_string(),
Some(usb) => String::from_utf8(usb.as_bytes().to_vec())?,
},
Some(usb) => String::from_utf8(usb.as_bytes().to_vec())?,
},
product: match groups.name("product") {
None => "Unk".to_string(),
Some(product) => String::from_utf8(product.as_bytes().to_vec())?,
Expand Down

0 comments on commit 95fe89a

Please sign in to comment.