#[derive(Debug, Clone, PartialEq, Eq, Default)]
#[non_exhaustive]
pub struct PolicyList {
pub policies: Vec<Policy>,
}
#[derive(Debug, Clone, PartialEq, Eq, Default)]
#[non_exhaustive]
pub struct Policy {
pub directives: Vec<Directive>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub struct Directive {
pub name: String,
pub raw_value: Option<String>,
}
impl Directive {
pub fn name_is_valid(&self) -> bool {
!self.name.is_empty()
&& self
.name
.bytes()
.all(|b| b.is_ascii_alphanumeric() || b == b'-')
}
pub fn value_is_valid(&self) -> bool {
match &self.raw_value {
None => true,
Some(value) => value.bytes().all(|b| {
b.is_ascii_whitespace() || matches!(b, 0x21..=0x2B | 0x2D..=0x3A | 0x3C..=0x7E)
}),
}
}
}