image4 0.8.2

A no_std-friendly library for parsing and generation of Image4 images written in pure Rust.
Documentation
mod borrowed;
#[cfg(any(feature = "alloc", test))]
mod owned;

/// Provides the [`CertIter`] type used to iterate [`CertChainRef`] and [`CertChain`] types.
pub mod iter {
    use super::CertRef;
    use crate::util;
    use core::iter::FusedIterator;
    use der::{Decode, Length, SliceReader};

    /// An iterator over certificates in [`CertChainRef`] and [`CertChain`] types.
    ///
    /// [`CertChainRef`]: super::CertChainRef
    /// [`CertChain`]: super::CertChain
    #[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};