Add partial Debug impls for Context and YubiKey (#457)
This enables `yubikey::Result<T>` to be debug-formatted, for example when wrapping the output of an API method in `dbg!()`.
This commit is contained in:
@@ -4,6 +4,7 @@ use crate::{Result, YubiKey};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
ffi::CStr,
|
||||
fmt,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
@@ -19,6 +20,12 @@ pub struct Context {
|
||||
reader_names: Vec<u8>,
|
||||
}
|
||||
|
||||
impl fmt::Debug for Context {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("Context").finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
||||
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).
|
||||
|
||||
@@ -156,6 +156,16 @@ pub struct YubiKey {
|
||||
pub(crate) serial: Serial,
|
||||
}
|
||||
|
||||
impl fmt::Debug for YubiKey {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("YubiKey")
|
||||
.field("name", &self.name)
|
||||
.field("version", &self.version)
|
||||
.field("serial", &self.serial)
|
||||
.finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
||||
impl YubiKey {
|
||||
/// Open a connection to a YubiKey.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user