openpgp-card/card-functionality/src/list-cards.rs
Heiko Schaefer c23f23c619
Introduce the new CardBackend trait.
A CardBackend represents a card without an open transaction (a CardTransaction implementation can be acquired from a CardBackend).
2022-02-18 15:06:31 +01:00

21 lines
581 B
Rust

// SPDX-FileCopyrightText: 2021 Heiko Schaefer <heiko@schaefer.name>
// SPDX-License-Identifier: MIT OR Apache-2.0
use anyhow::Result;
use openpgp_card::CardBackend;
use openpgp_card_pcsc::PcscCard;
use openpgp_card_sequoia::card::Open;
fn main() -> Result<()> {
println!("The following OpenPGP cards are connected to your system:");
for mut card in PcscCard::cards(None)? {
let mut txc = <dyn CardBackend>::transaction(&mut card)?;
let open = Open::new(&mut *txc)?;
println!(" {}", open.application_identifier()?.ident());
}
Ok(())
}