From 7565b3356831e5a07dae2b6b63235db326eef0b8 Mon Sep 17 00:00:00 2001 From: Archana Shinde Date: Mon, 10 Apr 2023 16:35:39 -0700 Subject: [PATCH] kata-ctl: Implement Display trait for GuestProtection enum Implement Display for enum to display in env output. Signed-off-by: Archana Shinde --- src/tools/kata-ctl/src/check.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/tools/kata-ctl/src/check.rs b/src/tools/kata-ctl/src/check.rs index dfb9a3b7b..bd5406bb8 100644 --- a/src/tools/kata-ctl/src/check.rs +++ b/src/tools/kata-ctl/src/check.rs @@ -8,6 +8,7 @@ use anyhow::{anyhow, Result}; use reqwest::header::{CONTENT_TYPE, USER_AGENT}; use serde::{Deserialize, Serialize}; +use std::fmt; use thiserror::Error; #[cfg(any(target_arch = "x86_64"))] @@ -147,6 +148,19 @@ pub enum GuestProtection { Se, } +impl fmt::Display for GuestProtection { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + GuestProtection::Tdx => write!(f, "tdx"), + GuestProtection::Sev => write!(f, "sev"), + GuestProtection::Snp => write!(f, "snp"), + GuestProtection::Pef => write!(f, "pef"), + GuestProtection::Se => write!(f, "se"), + GuestProtection::NoProtection => write!(f, "none"), + } + } +} + #[allow(dead_code)] #[derive(Error, Debug)] pub enum ProtectionError {