1use core_types::Timestamp;
2
3#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
5pub enum AlertSeverity {
6 Info,
8 Warn,
10 Error,
12 Critical,
14}
15
16impl AlertSeverity {
17 pub fn as_str(&self) -> &'static str {
18 match self {
19 Self::Info => "info",
20 Self::Warn => "warn",
21 Self::Error => "error",
22 Self::Critical => "critical",
23 }
24 }
25}
26
27#[derive(Clone, Debug)]
29pub struct Alert {
30 pub source: String,
32 pub code: String,
34 pub message: String,
36 pub severity: AlertSeverity,
38 pub timestamp: Timestamp,
40}
41
42impl Alert {
43 pub fn new(
44 source: impl Into<String>,
45 code: impl Into<String>,
46 message: impl Into<String>,
47 severity: AlertSeverity,
48 timestamp: Timestamp,
49 ) -> Self {
50 Self {
51 source: source.into(),
52 code: code.into(),
53 message: message.into(),
54 severity,
55 timestamp,
56 }
57 }
58}