diff --git a/CHANGELOG.md b/CHANGELOG.md index c5bec87..683add6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased +### Added +- `impl Debug for {Context, YubiKey}` + ## 0.7.0 (2022-11-14) ### Added - Display inner PC/SC errors ([#420]) diff --git a/src/reader.rs b/src/reader.rs index b3bbee7..caa5cf7 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -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, } +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). diff --git a/src/yubikey.rs b/src/yubikey.rs index 8ae98a6..9e93298 100644 --- a/src/yubikey.rs +++ b/src/yubikey.rs @@ -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. ///