Skip to content

Commit

Permalink
♻️ Concrete private struct EntryIterator
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanTsune committed Nov 16, 2023
1 parent 8346f2b commit 8420b36
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions lib/src/archive/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,13 @@ impl TryFrom<ChunkEntry> for EntryContainer {
}
}

struct EntryIterator<R: Read> {
entry: EntryReader<R>,
}
pub(crate) struct EntryIterator<'s>(EntryReader<&'s [u8]>);

impl<R: Read> Iterator for EntryIterator<R> {
impl Iterator for EntryIterator<'_> {
type Item = io::Result<ReadEntry>;

fn next(&mut self) -> Option<Self::Item> {
let mut chunk_reader = ChunkReader::from(&mut self.entry);
let mut chunk_reader = ChunkReader::from(&mut self.0);
let mut chunks = Vec::with_capacity(3);
loop {
let chunk = chunk_reader.read_chunk();
Expand Down Expand Up @@ -200,10 +198,7 @@ impl SolidEntries for SolidReadEntry {
}

impl SolidReadEntry {
pub(crate) fn entries(
&self,
password: Option<&str>,
) -> io::Result<impl Iterator<Item = io::Result<ReadEntry>> + '_> {
pub(crate) fn entries(&self, password: Option<&str>) -> io::Result<EntryIterator> {
let reader = decrypt_reader(
self.data.as_slice(),
self.header.encryption,
Expand All @@ -213,9 +208,7 @@ impl SolidReadEntry {
)?;
let reader = decompress_reader(reader, self.header.compression)?;

Ok(EntryIterator {
entry: EntryReader(reader),
})
Ok(EntryIterator(EntryReader(reader)))
}
}

Expand Down

0 comments on commit 8420b36

Please sign in to comment.