1 use super::graph::Graph; 2 use super::parse_util::UnitParseUtil; 3 4 use crate::error::parse_error::ParseError; 5 use crate::manager::UnitManager; 6 7 #[cfg(target_os = "dragonos")] 8 use drstd as std; 9 10 use std::string::ToString; 11 12 pub struct TargetParser; 13 14 impl TargetParser { 15 /// @brief 解析Service类型Unit的 16 /// 17 /// 从path解析Service类型Unit 18 /// 19 /// @param path 需解析的文件路径 20 /// 21 /// @return 成功则返回Ok(Rc<ServiceUnit>),否则返回Err 22 pub fn parse(path: &str) -> Result<usize, ParseError> { 23 //预先检查是否存在循环依赖 24 let mut graph = Graph::construct_graph(path.to_string())?; 25 let ret = graph.topological_sort()?; 26 for p in ret { 27 let _temp_unit = UnitParseUtil::parse_unit_no_type(&p)?; 28 } 29 30 let result = UnitManager::get_id_with_path(path).unwrap(); 31 return Ok(result); 32 } 33 } 34