guarding_core/rule_executor/
rule_error.rs

1use serde::{Deserialize, Serialize};
2
3#[repr(C)]
4#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
5pub enum MismatchType {
6    None,
7    Access,
8    FileName,
9    FileSize,
10}
11
12#[repr(C)]
13#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
14pub struct RuleErrorMsg {
15    pub expected: String,
16    pub actual: String,
17    pub mismatch_type: MismatchType,
18    pub msg: String,
19    pub items: Vec<String>,
20    pub rule_index: usize,
21}
22
23impl RuleErrorMsg {
24    pub fn new(mismatch_type: MismatchType, index: usize) -> RuleErrorMsg {
25        RuleErrorMsg {
26            expected: "".to_string(),
27            actual: "".to_string(),
28            mismatch_type,
29            msg: "".to_string(),
30            items: vec![],
31            rule_index: index
32        }
33    }
34}
35
36impl Default for RuleErrorMsg {
37    fn default() -> Self {
38        RuleErrorMsg {
39            expected: "".to_string(),
40            actual: "".to_string(),
41            mismatch_type: MismatchType::None,
42            msg: "".to_string(),
43            items: vec![],
44            rule_index: 0
45        }
46    }
47}