Skip to main content

rswappalyzer_engine/core/
rule.rs

1use rustc_hash::FxHashMap;
2use crate::CategoryRule;
3
4use super::basic_info::{CategoryEntry, TechBasicInfo};
5use super::enums::MatchScope;
6use super::pattern::MatchRuleSet;
7
8/// 解析后的标准化技术规则
9#[derive(Debug, Clone, Default, PartialEq)]
10pub struct ParsedTechRule {
11    pub basic: TechBasicInfo,
12    pub match_rules: FxHashMap<MatchScope, MatchRuleSet>,
13}
14
15impl From<&ParsedTechRule> for TechBasicInfo {
16    fn from(rule: &ParsedTechRule) -> Self {
17        rule.basic.clone()
18    }
19}
20
21/// 核心规则库结构体,业务层统一标准结构
22#[derive(Debug, Clone, Default, PartialEq)]
23pub struct RuleLibrary {
24    /// 核心技术规则(技术名称 → ParsedTechRule)
25    pub core_tech_map: FxHashMap<String, ParsedTechRule>,
26    /// 分类规则(ID → 分类信息)
27    pub category_rules: FxHashMap<u32, CategoryRule>,
28}
29
30pub type CategoryJsonRoot = FxHashMap<String, CategoryEntry>;