From 955590ece4ea084b49cc422a0bf3384c71bef48b Mon Sep 17 00:00:00 2001 From: Patrick Beza Date: Thu, 5 Sep 2024 11:34:12 +0200 Subject: [PATCH] Fixes --- core/lib/basic_types/src/tee_types.rs | 34 ++++----------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/core/lib/basic_types/src/tee_types.rs b/core/lib/basic_types/src/tee_types.rs index 4665c07ac0ad..9fd93a164fff 100644 --- a/core/lib/basic_types/src/tee_types.rs +++ b/core/lib/basic_types/src/tee_types.rs @@ -1,5 +1,3 @@ -use std::{fmt, str::FromStr}; - use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] @@ -9,23 +7,6 @@ pub enum TeeType { Sgx, } -impl fmt::Display for TeeType { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - TeeType::Sgx => write!(f, "sgx"), - } - } -} - -impl FromStr for TeeType { - type Err = String; - - fn from_str(s: &str) -> Result { - serde_json::from_str(&format!("\"{}\"", s.to_lowercase())) - .map_err(|_| format!("Invalid value for TeeType: {}", s)) - } -} - #[cfg(test)] mod tests { use serde_json; @@ -33,7 +14,7 @@ mod tests { use super::*; #[test] - fn test_deserialize_teetype() { + fn test_serialize_teetype() { let json_str = "\"sgx\""; let tee_type: TeeType = serde_json::from_str(json_str).unwrap(); assert_eq!(tee_type, TeeType::Sgx); @@ -45,14 +26,9 @@ mod tests { } #[test] - fn test_enumstring_teetype() { - assert_eq!(TeeType::from_str("sgx").unwrap(), TeeType::Sgx); - assert_eq!(TeeType::from_str("Sgx").unwrap(), TeeType::Sgx); - assert_eq!(TeeType::from_str("SGX").unwrap(), TeeType::Sgx); - } - - #[test] - fn test_display_teetype() { - assert_eq!(TeeType::Sgx.to_string(), "sgx"); + fn test_deserialize_teetype() { + let tee_type = TeeType::Sgx; + let json_str = serde_json::to_string(&tee_type).unwrap(); + assert_eq!(json_str, "\"sgx\""); } }