Skip to main content

sentio_core/
registry.rs

1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2pub struct RuleId(pub &'static str);
3
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub struct Rule {
6    pub id: RuleId,
7    pub title: &'static str,
8    pub default_enabled: bool,
9}
10
11#[derive(Debug, Default)]
12pub struct RuleCatalog {
13    rules: Vec<Rule>,
14}
15
16impl RuleCatalog {
17    pub fn new(rules: Vec<Rule>) -> Self {
18        Self { rules }
19    }
20
21    pub fn all(&self) -> &[Rule] {
22        &self.rules
23    }
24}
25
26impl Default for Rule {
27    fn default() -> Self {
28        Self {
29            id: RuleId("SW000"),
30            title: "placeholder rule",
31            default_enabled: true,
32        }
33    }
34}
35
36impl RuleCatalog {
37    pub fn baseline() -> Self {
38        Self::new(vec![
39            Rule {
40                id: RuleId("SW012"),
41                title: "Missing seeds + bump on PDA",
42                default_enabled: true,
43            },
44            Rule {
45                id: RuleId("SW016"),
46                title: "init_if_needed usage (manual review)",
47                default_enabled: true,
48            },
49        ])
50    }
51}