mod.rs 830 B

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