Extract slot UI indexing into util functions

This commit is contained in:
Jack Grigg
2021-03-29 19:17:44 +13:00
parent 850f96cd2c
commit 4ea8506e49
3 changed files with 21 additions and 24 deletions
+3 -3
View File
@@ -2,7 +2,7 @@ use std::fmt;
use std::io;
use yubikey_piv::{key::RetiredSlotId, Serial};
use crate::USABLE_SLOTS;
use crate::util::slot_to_ui;
pub enum Error {
CustomManagementKey,
@@ -84,12 +84,12 @@ impl fmt::Debug for Error {
Error::SlotHasNoIdentity(slot) => writeln!(
f,
"Slot {} does not contain an age identity or compatible key.",
USABLE_SLOTS.iter().position(|s| s == slot).unwrap() + 1
slot_to_ui(slot)
)?,
Error::SlotIsNotEmpty(slot) => writeln!(
f,
"Slot {} is not empty. Use --force to overwrite the slot.",
USABLE_SLOTS.iter().position(|s| s == slot).unwrap() + 1
slot_to_ui(slot)
)?,
Error::TimedOut => {
writeln!(f, "Timed out while waiting for a YubiKey to be inserted.")?