Add Display formatter to SlotId (#353)

This commit is contained in:
Ferdinand Linnenberg
2022-02-11 22:10:53 +01:00
committed by GitHub
parent e21395c934
commit 83de59983f
2 changed files with 49 additions and 0 deletions
+16
View File
@@ -57,6 +57,7 @@ use log::{debug, error, warn};
use p256::NistP256;
use p384::NistP384;
use rsa::{BigUint, RsaPublicKey};
use std::fmt::{Display, Formatter};
use std::str::FromStr;
#[cfg(feature = "untested")]
@@ -153,6 +154,15 @@ impl From<SlotId> for u8 {
}
}
impl Display for SlotId {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
SlotId::Retired(r) => write!(f, "{:?}", r),
_ => write!(f, "{:?}", self),
}
}
}
impl FromStr for SlotId {
type Err = Error;
@@ -295,6 +305,12 @@ impl From<RetiredSlotId> for u8 {
}
}
impl Display for RetiredSlotId {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}
impl RetiredSlotId {
/// Returns the [`ObjectId`] that corresponds to a given [`RetiredSlotId`].
pub(crate) fn object_id(self) -> ObjectId {