use super::{
AllowRule,
FieldMatchKind,
SensitiveFieldRule,
Sensitivity,
};
#[must_use]
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FieldClassification<'a> {
Sensitive {
rule: SensitiveFieldRule<'a>,
match_kind: FieldMatchKind,
},
Allowed {
rule: AllowRule<'a>,
match_kind: FieldMatchKind,
},
Unknown,
}
impl<'a> FieldClassification<'a> {
#[must_use]
pub const fn sensitivity(self) -> Option<Sensitivity> {
match self {
Self::Sensitive { rule, .. } => Some(rule.sensitivity()),
Self::Allowed { .. } | Self::Unknown => None,
}
}
#[must_use]
pub const fn matched_field(self) -> Option<&'a str> {
match self {
Self::Sensitive { rule, .. } => Some(rule.field()),
Self::Allowed { rule, .. } => Some(rule.field()),
Self::Unknown => None,
}
}
#[must_use]
pub const fn match_kind(self) -> Option<FieldMatchKind> {
match self {
Self::Sensitive { match_kind, .. }
| Self::Allowed { match_kind, .. } => Some(match_kind),
Self::Unknown => None,
}
}
#[must_use]
pub const fn is_allowed(self) -> bool {
matches!(self, Self::Allowed { .. })
}
#[must_use]
pub const fn is_unknown(self) -> bool {
matches!(self, Self::Unknown)
}
}