// SPDX-License-Identifier: Apache-2.0 use detee_shared::sgx::types::brain::AppDeployConfig; use detee_shared::sgx::types::dtpm::DtpmConfig; #[derive(thiserror::Error, Debug)] pub enum Error { #[error("Disk Access Error: {0}")] DiskAccess(#[from] std::io::Error), #[error("Yaml Error: {0}")] SerdeYaml(#[from] serde_yaml::Error), #[error("App launch config Error: {0}")] DtpmConfig(#[from] detee_shared::sgx::types::dtpm::Error), } type Result = std::result::Result; #[allow(dead_code)] pub trait DeteeCliExt { fn from_path(path: &str) -> Result where Self: std::marker::Sized; } impl DeteeCliExt for AppDeployConfig { fn from_path(path: &str) -> Result { let config_str = std::fs::read_to_string(path)?; Ok(serde_yaml::from_str(&config_str)?) } } pub fn validate_yaml(file_path: &str) -> Result { let parsed_config = DtpmConfig::from_path(file_path)?; let loaded_config = parsed_config.clone().load_data()?; Ok(loaded_config) }