clippy fixes
This commit is contained in:
+1
-6
@@ -291,12 +291,7 @@ fn main() -> Result<(), Error> {
|
|||||||
eprintln!("make your choice, or press [Esc] or [q] to quit.");
|
eprintln!("make your choice, or press [Esc] or [q] to quit.");
|
||||||
eprintln!();
|
eprintln!();
|
||||||
|
|
||||||
if Readers::open()?
|
if !Readers::open()?.iter()?.any(yubikey::is_connected) {
|
||||||
.iter()?
|
|
||||||
.filter(yubikey::filter_connected)
|
|
||||||
.next()
|
|
||||||
.is_none()
|
|
||||||
{
|
|
||||||
eprintln!("⏳ Please insert the YubiKey you want to set up.");
|
eprintln!("⏳ Please insert the YubiKey you want to set up.");
|
||||||
};
|
};
|
||||||
let mut readers = yubikey::wait_for_readers()?;
|
let mut readers = yubikey::wait_for_readers()?;
|
||||||
|
|||||||
+6
-7
@@ -33,6 +33,10 @@ use crate::{
|
|||||||
const ONE_SECOND: Duration = Duration::from_secs(1);
|
const ONE_SECOND: Duration = Duration::from_secs(1);
|
||||||
const FIFTEEN_SECONDS: Duration = Duration::from_secs(15);
|
const FIFTEEN_SECONDS: Duration = Duration::from_secs(15);
|
||||||
|
|
||||||
|
pub(crate) fn is_connected(reader: Reader) -> bool {
|
||||||
|
filter_connected(&reader)
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn filter_connected(reader: &Reader) -> bool {
|
pub(crate) fn filter_connected(reader: &Reader) -> bool {
|
||||||
match reader.open() {
|
match reader.open() {
|
||||||
Ok(_) => true,
|
Ok(_) => true,
|
||||||
@@ -55,7 +59,7 @@ pub(crate) fn wait_for_readers() -> Result<Readers, Error> {
|
|||||||
let start = SystemTime::now();
|
let start = SystemTime::now();
|
||||||
loop {
|
loop {
|
||||||
let mut readers = Readers::open()?;
|
let mut readers = Readers::open()?;
|
||||||
if readers.iter()?.filter(filter_connected).next().is_some() {
|
if readers.iter()?.any(is_connected) {
|
||||||
break Ok(readers);
|
break Ok(readers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,12 +71,7 @@ pub(crate) fn wait_for_readers() -> Result<Readers, Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn open(serial: Option<Serial>) -> Result<YubiKey, Error> {
|
pub(crate) fn open(serial: Option<Serial>) -> Result<YubiKey, Error> {
|
||||||
if Readers::open()?
|
if !Readers::open()?.iter()?.any(is_connected) {
|
||||||
.iter()?
|
|
||||||
.filter(filter_connected)
|
|
||||||
.next()
|
|
||||||
.is_none()
|
|
||||||
{
|
|
||||||
if let Some(serial) = serial {
|
if let Some(serial) = serial {
|
||||||
eprintln!("⏳ Please insert the YubiKey with serial {}.", serial);
|
eprintln!("⏳ Please insert the YubiKey with serial {}.", serial);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user