1#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
4pub struct CheckResult {
5 pub plugin: String,
7 pub check: String,
9 pub severity: Severity,
11 pub message: String,
13 pub details: Option<String>,
15}
16
17#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
20pub enum Severity {
21 Pass,
23 Info,
25 Warn,
27 Fail,
29 Critical,
31}
32
33impl CheckResult {
34 pub fn pass(plugin: &str, check: &str, message: impl Into<String>) -> Self {
36 Self {
37 plugin: plugin.into(),
38 check: check.into(),
39 severity: Severity::Pass,
40 message: message.into(),
41 details: None,
42 }
43 }
44
45 pub fn info(plugin: &str, check: &str, message: impl Into<String>) -> Self {
47 Self {
48 plugin: plugin.into(),
49 check: check.into(),
50 severity: Severity::Info,
51 message: message.into(),
52 details: None,
53 }
54 }
55
56 pub fn warn(plugin: &str, check: &str, message: impl Into<String>) -> Self {
58 Self {
59 plugin: plugin.into(),
60 check: check.into(),
61 severity: Severity::Warn,
62 message: message.into(),
63 details: None,
64 }
65 }
66
67 pub fn fail(plugin: &str, check: &str, message: impl Into<String>) -> Self {
69 Self {
70 plugin: plugin.into(),
71 check: check.into(),
72 severity: Severity::Fail,
73 message: message.into(),
74 details: None,
75 }
76 }
77
78 pub fn critical(plugin: &str, check: &str, message: impl Into<String>) -> Self {
80 Self {
81 plugin: plugin.into(),
82 check: check.into(),
83 severity: Severity::Critical,
84 message: message.into(),
85 details: None,
86 }
87 }
88
89 pub fn with_details(mut self, details: impl Into<String>) -> Self {
91 self.details = Some(details.into());
92 self
93 }
94}