Rename readers module to reader; Readers => Context (#278)

Renames the `readers` module to be singular: `reader`.

Renames the former `readers::Readers` struct to `reader::Context`.
This commit is contained in:
Tony Arcieri (iqlusion)
2021-07-12 11:01:12 -07:00
committed by GitHub
parent e6cea2eca6
commit 227518dd1b
4 changed files with 20 additions and 11 deletions
+11 -2
View File
@@ -40,6 +40,15 @@
//!
//! NOTE: RSASSA-PSS signatures and RSA-OAEP encryption may be supportable (TBD)
//!
//! # Status
//!
//! Functionality which has been successfully tested is available by default.
//!
//! Any functionality which is gated on the `untested` feature has not been
//! properly tested and is not known to function correctly.
//!
//! If
//!
//! # History
//!
//! This library is a Rust translation of the [yubico-piv-tool] utility by
@@ -141,7 +150,7 @@ mod mscmap;
mod msroots;
pub mod piv;
mod policy;
pub mod readers;
pub mod reader;
mod serialization;
mod settings;
mod transaction;
@@ -155,7 +164,7 @@ pub use crate::{
mgm::{MgmKey, MgmType},
piv::Key,
policy::{PinPolicy, TouchPolicy},
readers::Readers,
reader::Context,
settings::{SettingSource, SettingValue},
yubikey::{CachedPin, Serial, Version, YubiKey},
};
+3 -3
View File
@@ -11,8 +11,8 @@ use std::{
/// Iterator over connected readers
pub type Iter<'ctx> = std::vec::IntoIter<Reader<'ctx>>;
/// Enumeration support for available readers
pub struct Readers {
/// PC/SC reader context: used to enumerate available PC/SC [`Reader`]s.
pub struct Context {
/// PC/SC context
ctx: Arc<Mutex<pcsc::Context>>,
@@ -20,7 +20,7 @@ pub struct Readers {
reader_names: Vec<u8>,
}
impl Readers {
impl Context {
/// Open a PC/SC context, which can be used to enumerate available PC/SC
/// readers (which can be used to connect to YubiKeys).
pub fn open() -> Result<Self> {
+4 -4
View File
@@ -38,7 +38,7 @@ use crate::{
error::{Error, Result},
mgm::MgmKey,
piv,
readers::{Reader, Readers},
reader::{Context, Reader},
transaction::Transaction,
};
use log::{error, info};
@@ -155,10 +155,10 @@ impl YubiKey {
///
/// If you need to operate in environments with more than one YubiKey
/// attached to the same system, use [`YubiKey::open_by_serial`] or
/// [`yubikey::Readers`][`Readers`] to select from the available
/// [`yubikey::reader::Context`][`Context`] to select from the available
/// PC/SC readers.
pub fn open() -> Result<Self> {
let mut readers = Readers::open().map_err(|e| match e {
let mut readers = Context::open().map_err(|e| match e {
Error::PcscError {
inner: Some(pcsc::Error::NoReadersAvailable),
} => Error::NotFound,
@@ -181,7 +181,7 @@ impl YubiKey {
/// Open a YubiKey with a specific serial number.
pub fn open_by_serial(serial: Serial) -> Result<Self> {
let mut readers = Readers::open().map_err(|e| match e {
let mut readers = Context::open().map_err(|e| match e {
Error::PcscError {
inner: Some(pcsc::Error::NoReadersAvailable),
} => Error::NotFound,