diff --git a/lib/src/archive/entry.rs b/lib/src/archive/entry.rs index 4056bcc1..988f23c2 100644 --- a/lib/src/archive/entry.rs +++ b/lib/src/archive/entry.rs @@ -38,10 +38,9 @@ pub trait Entry: SealedIntoChunks { /// Readable archive entry. pub trait ReadEntry: Entry { - type Reader: Read; fn header(&self) -> &EntryHeader; fn metadata(&self) -> &Metadata; - fn into_reader(self, option: ReadOption) -> io::Result; + fn into_reader(self, option: ReadOption) -> io::Result; } /// Solid mode entries block. @@ -71,8 +70,16 @@ impl Entry for ChunkEntry { } } -/// [`Read`] -pub struct EntryReader(DecompressReader<'static, DecryptReader>); +/// Reader for Entry data. this struct impl [`Read`] trait. +pub struct EntryDataReader(EntryReader>>); + +impl Read for EntryDataReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + self.0.read(buf) + } +} + +pub(crate) struct EntryReader(DecompressReader<'static, DecryptReader>); impl Read for EntryReader { fn read(&mut self, buf: &mut [u8]) -> io::Result { @@ -345,8 +352,6 @@ impl Entry for NonSolidReadEntry { } impl ReadEntry for NonSolidReadEntry { - type Reader = EntryReader>>; - #[inline] fn header(&self) -> &EntryHeader { &self.header @@ -358,13 +363,13 @@ impl ReadEntry for NonSolidReadEntry { } #[inline] - fn into_reader(self, option: ReadOption) -> io::Result { + fn into_reader(self, option: ReadOption) -> io::Result { self.reader(option.password.as_deref()) } } impl NonSolidReadEntry { - fn reader(self, password: Option<&str>) -> io::Result>>> { + fn reader(self, password: Option<&str>) -> io::Result { let raw_data_reader = io::Cursor::new(self.data); let decrypt_reader = decrypt_reader( raw_data_reader, @@ -374,7 +379,7 @@ impl NonSolidReadEntry { password, )?; let reader = decompress_reader(decrypt_reader, self.header.compression)?; - Ok(EntryReader(reader)) + Ok(EntryDataReader(EntryReader(reader))) } }