1pub trait MatchQuote {
2 fn match_quote(&self, line: &str) -> bool;
3}
4
5pub struct ExactMatch {
6 m: String,
7}
8impl ExactMatch {
9 pub fn new(m: String) -> Self {
10 ExactMatch { m }
11 }
12}
13impl MatchQuote for ExactMatch {
14 fn match_quote(&self, line: &str) -> bool {
15 self.m == line
16 }
17}
18pub struct PrefixMatch {
19 prefix: String,
20}
21impl MatchQuote for PrefixMatch {
22 fn match_quote(&self, line: &str) -> bool {
23 line.starts_with(&self.prefix)
24 }
25}
26impl PrefixMatch {
27 pub fn new(prefix: String) -> Self {
28 PrefixMatch { prefix }
29 }
30}
31pub struct TrimPrefixMatch {
32 prefix: String,
33}
34impl MatchQuote for TrimPrefixMatch {
35 fn match_quote(&self, line: &str) -> bool {
36 line.trim_start().starts_with(&self.prefix)
37 }
38}
39impl TrimPrefixMatch {
40 pub fn new(prefix: String) -> Self {
41 TrimPrefixMatch {
42 prefix: prefix.trim().to_string(),
43 }
44 }
45}
46pub struct TrimExactMatch {
47 m: String,
48}
49impl TrimExactMatch {
50 pub fn new(s: String) -> Self {
51 TrimExactMatch {
52 m: s.trim().to_string(),
53 }
54 }
55}
56
57impl MatchQuote for TrimExactMatch {
58 fn match_quote(&self, line: &str) -> bool {
59 self.m == line.trim()
60 }
61}
62
63pub struct KeywordMatch {
64 k: String,
65}
66impl KeywordMatch {
67 pub fn new(k: String) -> Self {
68 KeywordMatch { k }
69 }
70}
71
72impl MatchQuote for KeywordMatch {
73 fn match_quote(&self, line: &str) -> bool {
74 line.contains(&self.k)
75 }
76}
77
78pub struct ExcludeKeywordMatch {
79 e: String,
80}
81impl ExcludeKeywordMatch {
82 pub fn new(e: String) -> Self {
83 ExcludeKeywordMatch { e }
84 }
85}
86impl MatchQuote for ExcludeKeywordMatch {
87 fn match_quote(&self, line: &str) -> bool {
88 !line.contains(&self.e)
89 }
90}