From a3f2c930f239e5dc097b5280ff7507b526056aa2 Mon Sep 17 00:00:00 2001 From: Heiko Schaefer Date: Fri, 20 Aug 2021 10:43:43 +0200 Subject: [PATCH] Documentation. --- openpgp-card/src/errors.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/openpgp-card/src/errors.rs b/openpgp-card/src/errors.rs index 4a84f3d..62d885e 100644 --- a/openpgp-card/src/errors.rs +++ b/openpgp-card/src/errors.rs @@ -1,8 +1,18 @@ // SPDX-FileCopyrightText: 2021 Heiko Schaefer // SPDX-License-Identifier: MIT OR Apache-2.0 +//! Error types that are used by this crate. +//! +//! [`OpenpgpCardError`] is a wrapper enum for all error types that are used. +//! +//! The two main cases are: +//! - [`SmartcardError`], for problems on the reader/smartcard layer +//! - [`OcErrorStatus`] which models error statuses reported by the OpenPGP +//! card application + use thiserror::Error; +/// Enum that wraps the different error types that this crate can return #[derive(Error, Debug)] pub enum OpenpgpCardError { #[error("Error interacting with smartcard {0}")] @@ -30,6 +40,7 @@ impl From for OpenpgpCardError { } } +/// OpenPGP card "Status Byte" errors #[derive(Error, Debug)] pub enum OcErrorStatus { #[error("Selected file or DO in termination state")] @@ -101,6 +112,7 @@ pub enum OcErrorStatus { #[error("Unknown OpenPGP card status: [{0}, {1}]")] UnknownStatus(u8, u8), + /// This code is not an OpenPGP card status value #[error("Unexpected response length: {0}")] ResponseLength(usize), } @@ -137,6 +149,7 @@ impl From<(u8, u8)> for OcErrorStatus { } } +/// Errors on the smartcard/reader layer #[derive(Error, Debug)] pub enum SmartcardError { #[error("Failed to create a pcsc smartcard context {0}")]