sentinel_modsec/operators/
traits.rs1#[derive(Debug, Clone, Default)]
5pub struct OperatorResult {
6 pub matched: bool,
8 pub captures: Vec<String>,
10 pub matched_value: Option<String>,
12}
13
14impl OperatorResult {
15 pub fn no_match() -> Self {
17 Self {
18 matched: false,
19 captures: Vec::new(),
20 matched_value: None,
21 }
22 }
23
24 pub fn matched(value: String) -> Self {
26 Self {
27 matched: true,
28 captures: Vec::new(),
29 matched_value: Some(value),
30 }
31 }
32
33 pub fn matched_with_captures(value: String, captures: Vec<String>) -> Self {
35 Self {
36 matched: true,
37 captures,
38 matched_value: Some(value),
39 }
40 }
41}
42
43pub trait Operator: Send + Sync {
45 fn execute(&self, value: &str) -> OperatorResult;
47
48 fn name(&self) -> &'static str;
50
51 fn supports_capture(&self) -> bool {
53 false
54 }
55}