vector_tap/
notification.rs1#[derive(Debug, Clone, PartialEq, Eq)]
2pub struct Matched {
4 message: String,
5 pub pattern: String,
7}
8
9impl Matched {
10 pub fn new(pattern: String) -> Self {
11 Self {
12 message: format!("[tap] Pattern '{pattern}' successfully matched."),
13 pattern,
14 }
15 }
16}
17
18#[derive(Debug, Clone, PartialEq, Eq)]
19pub struct NotMatched {
21 message: String,
22 pub pattern: String,
24}
25
26impl NotMatched {
27 pub fn new(pattern: String) -> Self {
28 Self {
29 message: format!(
30 "[tap] Pattern '{pattern}' failed to match: will retry on configuration reload."
31 ),
32 pattern,
33 }
34 }
35}
36
37#[derive(Debug, Clone, PartialEq, Eq)]
38pub struct InvalidMatch {
41 message: String,
42 pattern: String,
44 invalid_matches: Vec<String>,
46}
47
48impl InvalidMatch {
49 pub fn new(message: String, pattern: String, invalid_matches: Vec<String>) -> Self {
50 Self {
51 message,
52 pattern,
53 invalid_matches,
54 }
55 }
56}
57
58#[derive(Debug, Clone, PartialEq, Eq)]
59pub enum Notification {
61 Matched(Matched),
62 NotMatched(NotMatched),
63 InvalidMatch(InvalidMatch),
64}
65
66impl Notification {
67 pub fn as_str(&self) -> &str {
68 match self {
69 Notification::Matched(n) => n.message.as_ref(),
70 Notification::NotMatched(n) => n.message.as_ref(),
71 Notification::InvalidMatch(n) => n.message.as_ref(),
72 }
73 }
74}