35 lines
981 B
Rust
35 lines
981 B
Rust
use detee_shared::sgx::types::{brain::AppDeployConfig, 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<T> = std::result::Result<T, Error>;
|
|
|
|
#[allow(dead_code)]
|
|
pub trait DeteeCliExt {
|
|
fn from_path(path: &str) -> Result<Self>
|
|
where
|
|
Self: std::marker::Sized;
|
|
}
|
|
|
|
impl DeteeCliExt for AppDeployConfig {
|
|
fn from_path(path: &str) -> Result<Self> {
|
|
let config_str = std::fs::read_to_string(path)?;
|
|
Ok(serde_yaml::from_str(&config_str)?)
|
|
}
|
|
}
|
|
|
|
pub fn validate_yaml(file_path: &str) -> Result<DtpmConfig> {
|
|
let parsed_config = DtpmConfig::from_path(file_path)?;
|
|
let loaded_config = parsed_config.clone().load_data()?;
|
|
|
|
Ok(loaded_config)
|
|
}
|