mod borrowed;
#[cfg(any(feature = "alloc", test))]
mod owned;
pub mod iter {
use super::CertRef;
use crate::util;
use core::iter::FusedIterator;
use der::{Decode, Length, SliceReader};
#[derive(Clone, Debug)]
pub struct CertIter<'a> {
pub(super) inner: &'a [u8],
pub(super) position: Length,
}
impl<'a> Iterator for CertIter<'a> {
type Item = der::Result<CertRef<'a>>;
fn next(&mut self) -> Option<Self::Item> {
(!self.inner.is_empty()).then(|| {
let mut decoder = SliceReader::new(self.inner)?;
CertRef::decode(&mut decoder)
.map_err(|e| util::shift_error_position(e, self.position))
})
}
}
impl FusedIterator for CertIter<'_> {}
}
pub use borrowed::{CertChainRef, CertRef};
#[cfg(any(feature = "alloc", test))]
pub use owned::{Cert, CertChain};