use super::FieldNameMatching;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct AllowRule<'a> {
field: &'a str,
matching: FieldNameMatching,
}
impl<'a> AllowRule<'a> {
#[must_use]
pub(super) const fn new(field: &'a str, matching: FieldNameMatching) -> Self {
Self { field, matching }
}
#[must_use]
#[inline(always)]
pub const fn field(&self) -> &'a str {
self.field
}
#[must_use]
#[inline(always)]
pub const fn matching(&self) -> FieldNameMatching {
self.matching
}
}
#[cfg(test)]
mod tests {
use super::AllowRule;
use crate::policy::FieldNameMatching;
#[test]
fn accessors_preserve_the_allow_rule_view() {
let rule = AllowRule::new("request_id", FieldNameMatching::Exact);
assert_eq!(rule.field(), "request_id");
assert_eq!(rule.matching(), FieldNameMatching::Exact);
}
}