#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct CheckResult {
pub plugin: String,
pub check: String,
pub severity: Severity,
pub message: String,
pub details: Option<String>,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub enum Severity {
Pass,
Info,
Warn,
Fail,
Critical,
}
impl CheckResult {
pub fn pass(plugin: &str, check: &str, message: impl Into<String>) -> Self {
Self {
plugin: plugin.into(),
check: check.into(),
severity: Severity::Pass,
message: message.into(),
details: None,
}
}
pub fn info(plugin: &str, check: &str, message: impl Into<String>) -> Self {
Self {
plugin: plugin.into(),
check: check.into(),
severity: Severity::Info,
message: message.into(),
details: None,
}
}
pub fn warn(plugin: &str, check: &str, message: impl Into<String>) -> Self {
Self {
plugin: plugin.into(),
check: check.into(),
severity: Severity::Warn,
message: message.into(),
details: None,
}
}
pub fn fail(plugin: &str, check: &str, message: impl Into<String>) -> Self {
Self {
plugin: plugin.into(),
check: check.into(),
severity: Severity::Fail,
message: message.into(),
details: None,
}
}
pub fn critical(plugin: &str, check: &str, message: impl Into<String>) -> Self {
Self {
plugin: plugin.into(),
check: check.into(),
severity: Severity::Critical,
message: message.into(),
details: None,
}
}
pub fn with_details(mut self, details: impl Into<String>) -> Self {
self.details = Some(details.into());
self
}
}