Add high level crate documentation.

This commit is contained in:
Heiko Schaefer 2021-09-10 17:02:04 +02:00
parent 93fa9d9650
commit a5b6ce468d

View file

@ -3,6 +3,45 @@
//! A higher-level wrapper around the openpgp-card crate. //! A higher-level wrapper around the openpgp-card crate.
//! It uses sequoia_openpgp for OpenPGP operations. //! It uses sequoia_openpgp for OpenPGP operations.
//!
//! # Backends
//!
//! To make use of this crate, you need to use a backend for communication
//! with cards. The suggested default backend is `openpgp-card-pcsc`.
//!
//! With `openpgp-card-pcsc` you can either open all available cards:
//!
//! ```no_run
//! use openpgp_card_pcsc::PcscClient;
//! use openpgp_card_sequoia::card::Open;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! for card in PcscClient::cards()? {
//! let open = Open::open_card(card)?;
//! println!("Found OpenPGP card with ident '{}'",
//! open.get_application_id()?.ident());
//! }
//! # Ok(())
//! # }
//! ```
//!
//! Or you can open one particular card, by ident:
//!
//! ```no_run
//! use openpgp_card_pcsc::PcscClient;
//! use openpgp_card_sequoia::card::Open;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let card = PcscClient::open_by_ident("abcd:12345678")?;
//! let open = Open::open_card(card)?;
//! # Ok(())
//! # }
//! ```
//!
//! # Use for cryptographic operations
//!
//! # Setting up and configuring a card
//!
use openpgp::packet::{key, Key}; use openpgp::packet::{key, Key};
use sequoia_openpgp as openpgp; use sequoia_openpgp as openpgp;