sentinel_modsec/variables/
tx.rs1use super::collection::{HashMapCollection, MutableCollection, Collection};
4use regex::Regex;
5
6#[derive(Debug, Clone, Default)]
8pub struct TxCollection {
9 data: HashMapCollection,
10}
11
12impl TxCollection {
13 pub fn new() -> Self {
15 Self::default()
16 }
17
18 pub fn clear(&mut self) {
20 self.data.clear();
21 }
22}
23
24impl Collection for TxCollection {
25 fn all(&self) -> Vec<(&str, &str)> {
26 self.data.all()
27 }
28
29 fn get(&self, key: &str) -> Option<Vec<&str>> {
30 self.data.get(key)
31 }
32
33 fn get_regex(&self, pattern: &Regex) -> Vec<(&str, &str)> {
34 self.data.get_regex(pattern)
35 }
36
37 fn count(&self) -> usize {
38 self.data.count()
39 }
40
41 fn count_key(&self, key: &str) -> usize {
42 self.data.count_key(key)
43 }
44}
45
46impl MutableCollection for TxCollection {
47 fn set(&mut self, key: String, value: String) {
48 self.data.set(key, value);
49 }
50
51 fn delete(&mut self, key: &str) {
52 self.data.delete(key);
53 }
54
55 fn increment(&mut self, key: &str, amount: i64) {
56 self.data.increment(key, amount);
57 }
58
59 fn decrement(&mut self, key: &str, amount: i64) {
60 self.data.decrement(key, amount);
61 }
62}