use vil_log::dict::register_str;
use crate::{config::EdgeConfig, error::EdgeFault, profile::EdgeProfile, targets::EdgeTarget};
pub fn create(target: EdgeTarget, profile: EdgeProfile) -> Result<EdgeConfig, EdgeFault> {
register_str("edge_deploy.create");
register_str(target.rustc_target_triple());
register_str(&profile.to_string());
let config = EdgeConfig::from_profile(target, profile);
if !config.validate() {
return Err(EdgeFault::InvalidProfile);
}
register_str("edge_deploy.config.ready");
register_str(&config.scheduler_mode.to_string());
Ok(config)
}
pub fn create_from_file(path: &std::path::Path) -> Result<EdgeConfig, EdgeFault> {
register_str("edge_deploy.create_from_file");
let config = EdgeConfig::from_file(path)?;
if !config.validate() {
return Err(EdgeFault::InvalidProfile);
}
register_str(config.target.rustc_target_triple());
register_str(&config.profile.to_string());
register_str("edge_deploy.config.loaded");
Ok(config)
}