From 2ae91738a4b04fce32e01644ff3987705329023d Mon Sep 17 00:00:00 2001 From: Laura Abbott Date: Wed, 10 Dec 2025 10:50:58 -0500 Subject: [PATCH] Implement a few `Display` traits --- verifier/src/lib.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index c4cb474..af08115 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -457,6 +457,19 @@ impl std::iter::IntoIterator for MeasurementSet { } } +impl std::fmt::Display for MeasurementSet { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + writeln!(f, "measurement set")?; + for m in &self.0 { + writeln!(f, " {}", m)?; + } + if self.0.is_empty() { + writeln!(f, "(set is empty)")?; + } + Ok(()) + } +} + /// A collection of measurement values that is used as a source of truth when /// appraising the set of measurements derived from an attestation. pub struct ReferenceMeasurements(pub(crate) HashSet); @@ -488,6 +501,19 @@ impl TryFrom<&[Corim]> for ReferenceMeasurements { } } +impl std::fmt::Display for ReferenceMeasurements { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + writeln!(f, "Reference measurements")?; + for m in &self.0 { + writeln!(f, " {}", m)?; + } + if self.0.is_empty() { + writeln!(f, "(set is empty)")?; + } + Ok(()) + } +} + /// Errors produced by the `verify_attestation` function #[derive(Debug, Error)] pub enum VerifyAttestationError {