feat: optimize code
This commit is contained in:
@@ -36,9 +36,15 @@ impl Command for CommandImpl {
|
||||
}
|
||||
|
||||
let mut yubi = Yubico::new();
|
||||
if let Ok(device) = yubi.find_yubikey() {
|
||||
success!("Found key, Vendor ID: {:?} Product ID {:?}", device.vendor_id, device.product_id);
|
||||
let device = match yubi.find_yubikey() {
|
||||
Ok(device) => device,
|
||||
Err(_) => {
|
||||
warning!("YubiKey not found");
|
||||
return Ok(Some(1));
|
||||
}
|
||||
};
|
||||
|
||||
success!("Found key, Vendor ID: {:?} Product ID {:?}", device.vendor_id, device.product_id);
|
||||
let config = Config::default()
|
||||
.set_vendor_id(device.vendor_id)
|
||||
.set_product_id(device.product_id)
|
||||
@@ -56,10 +62,6 @@ impl Command for CommandImpl {
|
||||
} else {
|
||||
success!("Device configured");
|
||||
}
|
||||
} else {
|
||||
warning!("YubiKey not found");
|
||||
return Ok(Some(1));
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user