use crate::constraints::CertificateCount;
use structured_asn1::Oid;
use structured_asn1::memory::{MemoryError, OwnedVec};
mod graph;
#[cfg(test)]
use graph::Node;
pub(super) use graph::Processing;
const WORKED: u64 = super::cost::ENTRY;
fn identified(policy: Oid<'_>) -> u64 {
policy.as_bytes().len() as u64 / super::cost::COMPARED
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub(super) enum Overflow {
Limit,
Resource(crate::Error),
}
impl From<crate::Error> for Overflow {
fn from(error: crate::Error) -> Self {
Self::Resource(error)
}
}
fn resource(reason: MemoryError, offset: u64) -> Overflow {
Overflow::Resource(crate::Error::resource(
reason,
"certificationPath.policies",
offset,
))
}
#[derive(Debug, Clone, Copy)]
pub(super) struct Initial {
pub(super) explicit_policy: bool,
pub(super) policy_mapping: bool,
pub(super) any_policy: bool,
}
impl Default for Initial {
fn default() -> Self {
Self {
explicit_policy: false,
policy_mapping: true,
any_policy: true,
}
}
}
#[derive(Debug)]
pub(super) struct Settled<'a> {
policies: OwnedVec<Oid<'a>>,
satisfied: bool,
}
impl<'a> Settled<'a> {
#[cfg(test)]
pub(super) fn policies(&self) -> &[Oid<'a>] {
&self.policies
}
pub(super) fn is_satisfied(&self) -> bool {
self.satisfied
}
pub(super) fn into_policies(self) -> OwnedVec<Oid<'a>> {
self.policies
}
}
fn narrow(counter: &mut u32, count: Option<CertificateCount>) {
if let Some(count) = count.and_then(CertificateCount::certificates)
&& count < *counter
{
*counter = count;
}
}
#[cfg(test)]
mod tests;