Rename list_cards() -> cards().
Remove open_yolo() from the openpgp-card-pcsc API (it's easy enough to approximate by using cards())
This commit is contained in:
parent
55e7a2c794
commit
936f04663c
3 changed files with 5 additions and 19 deletions
|
@ -97,7 +97,7 @@ impl TestCard {
|
|||
let res = ScdClient::shutdown_scd(None);
|
||||
log::trace!(" Attempt to shutdown scd: {:?}", res);
|
||||
|
||||
for card_client in PcscClient::list_cards()? {
|
||||
for card_client in PcscClient::cards()? {
|
||||
let mut ca = CardApp::from(card_client);
|
||||
|
||||
// Set Card Capabilities (chaining, command length, ..)
|
||||
|
|
|
@ -239,7 +239,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
|
||||
println!("The following OpenPGP cards are connected to your system:");
|
||||
|
||||
let cards = PcscClient::list_cards()?;
|
||||
let cards = PcscClient::cards()?;
|
||||
for c in cards {
|
||||
let mut ca = CardApp::from(c);
|
||||
|
||||
|
|
|
@ -82,7 +82,9 @@ impl PcscClient {
|
|||
}
|
||||
|
||||
/// Return all cards on which the OpenPGP application could be selected.
|
||||
pub fn list_cards() -> Result<Vec<CardClientBox>> {
|
||||
///
|
||||
/// Each card is opened and has the OpenPGP application selected.
|
||||
pub fn cards() -> Result<Vec<CardClientBox>> {
|
||||
let cards = Self::unopened_cards()?
|
||||
.into_iter()
|
||||
.map(Self::select)
|
||||
|
@ -106,22 +108,6 @@ impl PcscClient {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the first OpenPGP card, with the OpenPGP application selected.
|
||||
///
|
||||
/// If multiple cards are connected, this will effectively be a random
|
||||
/// pick. You should consider using `open_by_ident` instead.
|
||||
pub fn open_yolo() -> Result<CardClientBox, Error> {
|
||||
for card in Self::unopened_cards()? {
|
||||
if let Ok(ca) = Self::select(card) {
|
||||
return Ok(ca.into());
|
||||
}
|
||||
}
|
||||
|
||||
Err(Error::Smartcard(SmartcardError::CardNotFound(
|
||||
"No OpenPGP card found".to_string(),
|
||||
)))
|
||||
}
|
||||
|
||||
/// Get application related data from the card and check if 'ident'
|
||||
/// matches
|
||||
fn match_by_ident(
|
||||
|
|
Loading…
Reference in a new issue