kata-ctl: Implement Display trait for GuestProtection enum

Implement Display for enum to display in env output.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
This commit is contained in:
Archana Shinde 2023-04-10 16:35:39 -07:00
parent 94a00f9346
commit 7565b33568

View File

@ -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 {