use crate::validation::blocker::Blocker;
use crate::validation::report::CoverageKind;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum RuleStatus {
Error,
Warning,
Configurable,
MachineUncheckable,
Unimplemented,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
#[non_exhaustive]
pub enum ValidationGate {
#[default]
Always,
Compliant,
Complete,
BestPractice,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum NormativeSeverity {
Must,
Should,
May,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct ValidationRuleStatus {
pub rule: &'static str,
pub status: RuleStatus,
pub normative_severity: NormativeSeverity,
pub spec_section: &'static str,
pub note: &'static str,
pub blocker: Option<Blocker>,
pub validator_function: Option<&'static str>,
pub coverage_kind: Option<CoverageKind>,
pub gate: ValidationGate,
}
impl ValidationRuleStatus {
#[allow(clippy::too_many_arguments)]
pub const fn new(
rule: &'static str,
status: RuleStatus,
normative_severity: NormativeSeverity,
spec_section: &'static str,
note: &'static str,
blocker: Option<Blocker>,
validator_function: Option<&'static str>,
coverage_kind: Option<CoverageKind>,
gate: ValidationGate,
) -> Self {
Self {
rule,
status,
normative_severity,
spec_section,
note,
blocker,
validator_function,
coverage_kind,
gate,
}
}
pub fn is_machine_uncheckable(&self) -> bool {
matches!(self.status, RuleStatus::MachineUncheckable)
}
pub fn is_implemented(&self) -> bool {
matches!(
self.status,
RuleStatus::Error | RuleStatus::Warning | RuleStatus::Configurable
)
}
pub fn is_machine_checkable(&self) -> bool {
!matches!(self.status, RuleStatus::MachineUncheckable)
}
}