Skip to content

Commit 7edd937

Browse files
authored
feat: Use MultiGzDecoder to handle block gzip files (#538)
Use `MultiGzDecoder` rather than `GzDecoder` to handle block gzip files.
1 parent 3f70d1a commit 7edd937

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

martian-filetypes/src/gzip_file.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
use crate::{
3232
ErrorContext, FileTypeIO, FileTypeRead, FileTypeWrite, LazyAgents, LazyRead, LazyWrite,
3333
};
34-
use flate2::read::GzDecoder;
34+
use flate2::read::MultiGzDecoder;
3535
use flate2::write::GzEncoder;
3636
use flate2::Compression;
3737
use martian::{Error, MartianFileType};
@@ -50,7 +50,7 @@ where
5050
F: MartianFileType + FileTypeIO<T>,
5151
{
5252
fn read(&self) -> Result<T, Error> {
53-
let decoder = GzDecoder::new(self.buf_reader()?);
53+
let decoder = MultiGzDecoder::new(self.buf_reader()?);
5454
<Self as FileTypeRead<T>>::read_from(decoder).map_err(|e| {
5555
let context = ErrorContext::ReadContext(self.as_ref().into(), e.to_string());
5656
e.context(context)
@@ -143,7 +143,7 @@ where
143143
/// stores a list of items.
144144
pub struct LazyGzipReader<L, T, R>
145145
where
146-
L: LazyRead<T, GzDecoder<R>>,
146+
L: LazyRead<T, MultiGzDecoder<R>>,
147147
R: Read,
148148
{
149149
inner: L,
@@ -152,21 +152,21 @@ where
152152

153153
impl<L, T, R> LazyRead<T, R> for LazyGzipReader<L, T, R>
154154
where
155-
L: LazyRead<T, GzDecoder<R>>,
155+
L: LazyRead<T, MultiGzDecoder<R>>,
156156
R: Read,
157157
{
158158
type FileType = Gzip<L::FileType>;
159159
fn with_reader(reader: R) -> Result<Self, Error> {
160160
Ok(LazyGzipReader {
161-
inner: L::with_reader(GzDecoder::new(reader))?,
161+
inner: L::with_reader(MultiGzDecoder::new(reader))?,
162162
phantom: PhantomData,
163163
})
164164
}
165165
}
166166

167167
impl<L, T, R> Iterator for LazyGzipReader<L, T, R>
168168
where
169-
L: LazyRead<T, GzDecoder<R>>,
169+
L: LazyRead<T, MultiGzDecoder<R>>,
170170
R: Read,
171171
{
172172
type Item = Result<T, Error>;
@@ -179,7 +179,7 @@ impl<F, T, W, R> LazyAgents<T, W, R> for Gzip<F>
179179
where
180180
R: Read,
181181
W: Write,
182-
F: LazyAgents<T, GzEncoder<W>, GzDecoder<R>>,
182+
F: LazyAgents<T, GzEncoder<W>, MultiGzDecoder<R>>,
183183
{
184184
type LazyWriter = LazyGzipWriter<F::LazyWriter, T, W>;
185185
type LazyReader = LazyGzipReader<F::LazyReader, T, R>;

0 commit comments

Comments
 (0)