summaryrefslogtreecommitdiffstats
path: root/vendor/flate2/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/flate2/src
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/flate2/src')
-rw-r--r--vendor/flate2/src/crc.rs26
-rw-r--r--vendor/flate2/src/deflate/bufread.rs2
-rw-r--r--vendor/flate2/src/deflate/mod.rs16
-rw-r--r--vendor/flate2/src/deflate/read.rs2
-rw-r--r--vendor/flate2/src/ffi/c.rs8
-rw-r--r--vendor/flate2/src/ffi/rust.rs2
-rw-r--r--vendor/flate2/src/gz/bufread.rs18
-rw-r--r--vendor/flate2/src/gz/mod.rs10
-rw-r--r--vendor/flate2/src/gz/read.rs4
-rw-r--r--vendor/flate2/src/gz/write.rs136
-rw-r--r--vendor/flate2/src/lib.rs2
-rw-r--r--vendor/flate2/src/mem.rs36
-rw-r--r--vendor/flate2/src/zio.rs6
-rw-r--r--vendor/flate2/src/zlib/bufread.rs2
-rw-r--r--vendor/flate2/src/zlib/mod.rs14
-rw-r--r--vendor/flate2/src/zlib/read.rs2
16 files changed, 195 insertions, 91 deletions
diff --git a/vendor/flate2/src/crc.rs b/vendor/flate2/src/crc.rs
index cd00cebe1..16f560196 100644
--- a/vendor/flate2/src/crc.rs
+++ b/vendor/flate2/src/crc.rs
@@ -63,13 +63,13 @@ impl Crc {
/// Combine the CRC with the CRC for the subsequent block of bytes.
pub fn combine(&mut self, additional_crc: &Crc) {
- self.amt += additional_crc.amt;
+ self.amt = self.amt.wrapping_add(additional_crc.amt);
self.hasher.combine(&additional_crc.hasher);
}
}
impl<R: Read> CrcReader<R> {
- /// Create a new CrcReader.
+ /// Create a new `CrcReader`.
pub fn new(r: R) -> CrcReader<R> {
CrcReader {
inner: r,
@@ -79,27 +79,27 @@ impl<R: Read> CrcReader<R> {
}
impl<R> CrcReader<R> {
- /// Get the Crc for this CrcReader.
+ /// Get the Crc for this `CrcReader`.
pub fn crc(&self) -> &Crc {
&self.crc
}
- /// Get the reader that is wrapped by this CrcReader.
+ /// Get the reader that is wrapped by this `CrcReader`.
pub fn into_inner(self) -> R {
self.inner
}
- /// Get the reader that is wrapped by this CrcReader by reference.
+ /// Get the reader that is wrapped by this `CrcReader` by reference.
pub fn get_ref(&self) -> &R {
&self.inner
}
- /// Get a mutable reference to the reader that is wrapped by this CrcReader.
+ /// Get a mutable reference to the reader that is wrapped by this `CrcReader`.
pub fn get_mut(&mut self) -> &mut R {
&mut self.inner
}
- /// Reset the Crc in this CrcReader.
+ /// Reset the Crc in this `CrcReader`.
pub fn reset(&mut self) {
self.crc.reset();
}
@@ -135,34 +135,34 @@ pub struct CrcWriter<W> {
}
impl<W> CrcWriter<W> {
- /// Get the Crc for this CrcWriter.
+ /// Get the Crc for this `CrcWriter`.
pub fn crc(&self) -> &Crc {
&self.crc
}
- /// Get the writer that is wrapped by this CrcWriter.
+ /// Get the writer that is wrapped by this `CrcWriter`.
pub fn into_inner(self) -> W {
self.inner
}
- /// Get the writer that is wrapped by this CrcWriter by reference.
+ /// Get the writer that is wrapped by this `CrcWriter` by reference.
pub fn get_ref(&self) -> &W {
&self.inner
}
- /// Get a mutable reference to the writer that is wrapped by this CrcWriter.
+ /// Get a mutable reference to the writer that is wrapped by this `CrcWriter`.
pub fn get_mut(&mut self) -> &mut W {
&mut self.inner
}
- /// Reset the Crc in this CrcWriter.
+ /// Reset the Crc in this `CrcWriter`.
pub fn reset(&mut self) {
self.crc.reset();
}
}
impl<W: Write> CrcWriter<W> {
- /// Create a new CrcWriter.
+ /// Create a new `CrcWriter`.
pub fn new(w: W) -> CrcWriter<W> {
CrcWriter {
inner: w,
diff --git a/vendor/flate2/src/deflate/bufread.rs b/vendor/flate2/src/deflate/bufread.rs
index f0b29e0b4..e375952d0 100644
--- a/vendor/flate2/src/deflate/bufread.rs
+++ b/vendor/flate2/src/deflate/bufread.rs
@@ -202,7 +202,7 @@ impl<R> DeflateDecoder<R> {
/// Acquires a mutable reference to the underlying stream
///
/// Note that mutation of the stream may result in surprising results if
- /// this encoder is continued to be used.
+ /// this decoder is continued to be used.
pub fn get_mut(&mut self) -> &mut R {
&mut self.obj
}
diff --git a/vendor/flate2/src/deflate/mod.rs b/vendor/flate2/src/deflate/mod.rs
index 51758b30a..7f3bf70fd 100644
--- a/vendor/flate2/src/deflate/mod.rs
+++ b/vendor/flate2/src/deflate/mod.rs
@@ -18,14 +18,14 @@ mod tests {
let v = crate::random_bytes().take(1024).collect::<Vec<_>>();
for _ in 0..200 {
let to_write = &v[..thread_rng().gen_range(0..v.len())];
- real.extend(to_write.iter().map(|x| *x));
+ real.extend(to_write.iter().copied());
w.write_all(to_write).unwrap();
}
let result = w.finish().unwrap();
let mut r = read::DeflateDecoder::new(&result[..]);
let mut ret = Vec::new();
r.read_to_end(&mut ret).unwrap();
- assert!(ret == real);
+ assert_eq!(ret, real);
}
#[test]
@@ -37,7 +37,7 @@ mod tests {
let mut r = read::DeflateDecoder::new(&data[..]);
let mut ret = Vec::new();
r.read_to_end(&mut ret).unwrap();
- assert!(ret == b"foo");
+ assert_eq!(ret, b"foo");
}
#[test]
@@ -47,7 +47,7 @@ mod tests {
let v = crate::random_bytes().take(1024).collect::<Vec<_>>();
for _ in 0..200 {
let to_write = &v[..thread_rng().gen_range(0..v.len())];
- real.extend(to_write.iter().map(|x| *x));
+ real.extend(to_write.iter().copied());
w.write_all(to_write).unwrap();
}
let mut result = w.finish().unwrap();
@@ -55,13 +55,13 @@ mod tests {
let result_len = result.len();
for _ in 0..200 {
- result.extend(v.iter().map(|x| *x));
+ result.extend(v.iter().copied());
}
let mut r = read::DeflateDecoder::new(&result[..]);
let mut ret = Vec::new();
r.read_to_end(&mut ret).unwrap();
- assert!(ret == real);
+ assert_eq!(ret, real);
assert_eq!(r.total_in(), result_len as u64);
}
@@ -84,7 +84,7 @@ mod tests {
);
w.write_all(&v).unwrap();
let w = w.finish().unwrap().finish().unwrap();
- assert!(w == v);
+ assert_eq!(w, v);
}
#[test]
@@ -159,7 +159,7 @@ mod tests {
let mut d = read::DeflateDecoder::new(&result[..]);
let mut data = Vec::new();
- assert!(d.read(&mut data).unwrap() == 0);
+ assert_eq!(d.read(&mut data).unwrap(), 0);
}
#[test]
diff --git a/vendor/flate2/src/deflate/read.rs b/vendor/flate2/src/deflate/read.rs
index fd17a894a..e6af130a3 100644
--- a/vendor/flate2/src/deflate/read.rs
+++ b/vendor/flate2/src/deflate/read.rs
@@ -196,7 +196,7 @@ impl<R> DeflateDecoder<R> {
/// Acquires a mutable reference to the underlying stream
///
/// Note that mutation of the stream may result in surprising results if
- /// this encoder is continued to be used.
+ /// this decoder is continued to be used.
pub fn get_mut(&mut self) -> &mut R {
self.inner.get_mut().get_mut()
}
diff --git a/vendor/flate2/src/ffi/c.rs b/vendor/flate2/src/ffi/c.rs
index 59e20118f..48acd438c 100644
--- a/vendor/flate2/src/ffi/c.rs
+++ b/vendor/flate2/src/ffi/c.rs
@@ -215,9 +215,9 @@ impl InflateBackend for Inflate {
let raw = &mut *self.inner.stream_wrapper;
raw.msg = ptr::null_mut();
raw.next_in = input.as_ptr() as *mut u8;
- raw.avail_in = cmp::min(input.len(), c_uint::max_value() as usize) as c_uint;
+ raw.avail_in = cmp::min(input.len(), c_uint::MAX as usize) as c_uint;
raw.next_out = output.as_mut_ptr();
- raw.avail_out = cmp::min(output.len(), c_uint::max_value() as usize) as c_uint;
+ raw.avail_out = cmp::min(output.len(), c_uint::MAX as usize) as c_uint;
let rc = unsafe { mz_inflate(raw, flush as c_int) };
@@ -303,9 +303,9 @@ impl DeflateBackend for Deflate {
let raw = &mut *self.inner.stream_wrapper;
raw.msg = ptr::null_mut();
raw.next_in = input.as_ptr() as *mut _;
- raw.avail_in = cmp::min(input.len(), c_uint::max_value() as usize) as c_uint;
+ raw.avail_in = cmp::min(input.len(), c_uint::MAX as usize) as c_uint;
raw.next_out = output.as_mut_ptr();
- raw.avail_out = cmp::min(output.len(), c_uint::max_value() as usize) as c_uint;
+ raw.avail_out = cmp::min(output.len(), c_uint::MAX as usize) as c_uint;
let rc = unsafe { mz_deflate(raw, flush as c_int) };
diff --git a/vendor/flate2/src/ffi/rust.rs b/vendor/flate2/src/ffi/rust.rs
index eadd6ec18..bed6629a2 100644
--- a/vendor/flate2/src/ffi/rust.rs
+++ b/vendor/flate2/src/ffi/rust.rs
@@ -1,4 +1,4 @@
-//! Implementation for miniz_oxide rust backend.
+//! Implementation for `miniz_oxide` rust backend.
use std::convert::TryInto;
use std::fmt;
diff --git a/vendor/flate2/src/gz/bufread.rs b/vendor/flate2/src/gz/bufread.rs
index 6be144d0c..c6ac5a98b 100644
--- a/vendor/flate2/src/gz/bufread.rs
+++ b/vendor/flate2/src/gz/bufread.rs
@@ -74,7 +74,7 @@ fn read_gz_header_part<'a, R: Read>(r: &'a mut Buffer<'a, R>) -> io::Result<()>
}
GzHeaderParsingState::Filename => {
if r.part.flg & FNAME != 0 {
- if None == r.part.header.filename {
+ if r.part.header.filename.is_none() {
r.part.header.filename = Some(Vec::new());
};
for byte in r.bytes() {
@@ -88,7 +88,7 @@ fn read_gz_header_part<'a, R: Read>(r: &'a mut Buffer<'a, R>) -> io::Result<()>
}
GzHeaderParsingState::Comment => {
if r.part.flg & FCOMMENT != 0 {
- if None == r.part.header.comment {
+ if r.part.header.comment.is_none() {
r.part.header.comment = Some(Vec::new());
};
for byte in r.bytes() {
@@ -483,7 +483,7 @@ impl<R> GzDecoder<R> {
/// Acquires a mutable reference to the underlying stream.
///
/// Note that mutation of the stream may result in surprising results if
- /// this encoder is continued to be used.
+ /// this decoder is continued to be used.
pub fn get_mut(&mut self) -> &mut R {
self.reader.get_mut().get_mut()
}
@@ -681,7 +681,7 @@ impl<R> MultiGzDecoder<R> {
/// Acquires a mutable reference to the underlying stream.
///
/// Note that mutation of the stream may result in surprising results if
- /// this encoder is continued to be used.
+ /// this decoder is continued to be used.
pub fn get_mut(&mut self) -> &mut R {
self.0.get_mut()
}
@@ -718,20 +718,20 @@ pub mod tests {
}
pub fn set_position(&mut self, pos: u64) {
- return self.cursor.set_position(pos);
+ self.cursor.set_position(pos)
}
pub fn position(&mut self) -> u64 {
- return self.cursor.position();
+ self.cursor.position()
}
}
impl Write for BlockingCursor {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
- return self.cursor.write(buf);
+ self.cursor.write(buf)
}
fn flush(&mut self) -> io::Result<()> {
- return self.cursor.flush();
+ self.cursor.flush()
}
}
@@ -751,7 +751,7 @@ pub mod tests {
}
Ok(_n) => {}
}
- return r;
+ r
}
}
#[test]
diff --git a/vendor/flate2/src/gz/mod.rs b/vendor/flate2/src/gz/mod.rs
index 505450e3e..d31aa60be 100644
--- a/vendor/flate2/src/gz/mod.rs
+++ b/vendor/flate2/src/gz/mod.rs
@@ -218,11 +218,11 @@ impl GzBuilder {
}
if let Some(filename) = filename {
flg |= FNAME;
- header.extend(filename.as_bytes_with_nul().iter().map(|x| *x));
+ header.extend(filename.as_bytes_with_nul().iter().copied());
}
if let Some(comment) = comment {
flg |= FCOMMENT;
- header.extend(comment.as_bytes_with_nul().iter().map(|x| *x));
+ header.extend(comment.as_bytes_with_nul().iter().copied());
}
header[0] = 0x1f;
header[1] = 0x8b;
@@ -285,14 +285,14 @@ mod tests {
let v = crate::random_bytes().take(1024).collect::<Vec<_>>();
for _ in 0..200 {
let to_write = &v[..thread_rng().gen_range(0..v.len())];
- real.extend(to_write.iter().map(|x| *x));
+ real.extend(to_write.iter().copied());
w.write_all(to_write).unwrap();
}
let result = w.finish().unwrap();
let mut r = read::GzDecoder::new(&result[..]);
let mut v = Vec::new();
r.read_to_end(&mut v).unwrap();
- assert!(v == real);
+ assert_eq!(v, real);
}
#[test]
@@ -301,7 +301,7 @@ mod tests {
let mut r = read::GzDecoder::new(read::GzEncoder::new(&v[..], Compression::default()));
let mut res = Vec::new();
r.read_to_end(&mut res).unwrap();
- assert!(res == v);
+ assert_eq!(res, v);
}
#[test]
diff --git a/vendor/flate2/src/gz/read.rs b/vendor/flate2/src/gz/read.rs
index dbbe63282..cfeb992e8 100644
--- a/vendor/flate2/src/gz/read.rs
+++ b/vendor/flate2/src/gz/read.rs
@@ -153,7 +153,7 @@ impl<R> GzDecoder<R> {
/// Acquires a mutable reference to the underlying stream.
///
/// Note that mutation of the stream may result in surprising results if
- /// this encoder is continued to be used.
+ /// this decoder is continued to be used.
pub fn get_mut(&mut self) -> &mut R {
self.inner.get_mut().get_mut()
}
@@ -250,7 +250,7 @@ impl<R> MultiGzDecoder<R> {
/// Acquires a mutable reference to the underlying stream.
///
/// Note that mutation of the stream may result in surprising results if
- /// this encoder is continued to be used.
+ /// this decoder is continued to be used.
pub fn get_mut(&mut self) -> &mut R {
self.inner.get_mut().get_mut()
}
diff --git a/vendor/flate2/src/gz/write.rs b/vendor/flate2/src/gz/write.rs
index 7cf1a7cd4..83eebb757 100644
--- a/vendor/flate2/src/gz/write.rs
+++ b/vendor/flate2/src/gz/write.rs
@@ -92,7 +92,7 @@ impl<W: Write> GzEncoder<W> {
self.inner.finish()?;
while self.crc_bytes_written < 8 {
- let (sum, amt) = (self.crc.sum() as u32, self.crc.amount());
+ let (sum, amt) = (self.crc.sum(), self.crc.amount());
let buf = [
(sum >> 0) as u8,
(sum >> 8) as u8,
@@ -169,7 +169,7 @@ impl<W: Write> Drop for GzEncoder<W> {
/// A gzip streaming decoder
///
-/// This structure exposes a [`Write`] interface that will emit compressed data
+/// This structure exposes a [`Write`] interface that will emit uncompressed data
/// to the underlying writer `W`.
///
/// [`Write`]: https://doc.rust-lang.org/std/io/trait.Write.html
@@ -296,7 +296,7 @@ impl<W: Write> GzDecoder<W> {
| ((self.crc_bytes[5] as u32) << 8)
| ((self.crc_bytes[6] as u32) << 16)
| ((self.crc_bytes[7] as u32) << 24);
- if crc != self.inner.get_ref().crc().sum() as u32 {
+ if crc != self.inner.get_ref().crc().sum() {
return Err(corrupt());
}
if amt != self.inner.get_ref().crc().amount() {
@@ -373,11 +373,117 @@ impl<W: Read + Write> Read for GzDecoder<W> {
}
}
+/// A gzip streaming decoder that decodes all members of a multistream
+///
+/// A gzip member consists of a header, compressed data and a trailer. The [gzip
+/// specification](https://tools.ietf.org/html/rfc1952), however, allows multiple
+/// gzip members to be joined in a single stream. `MultiGzDecoder` will
+/// decode all consecutive members while `GzDecoder` will only decompress
+/// the first gzip member. The multistream format is commonly used in
+/// bioinformatics, for example when using the BGZF compressed data.
+///
+/// This structure exposes a [`Write`] interface that will consume all gzip members
+/// from the written buffers and write uncompressed data to the writer.
+#[derive(Debug)]
+pub struct MultiGzDecoder<W: Write> {
+ inner: GzDecoder<W>,
+}
+
+impl<W: Write> MultiGzDecoder<W> {
+ /// Creates a new decoder which will write uncompressed data to the stream.
+ /// If the gzip stream contains multiple members all will be decoded.
+ pub fn new(w: W) -> MultiGzDecoder<W> {
+ MultiGzDecoder {
+ inner: GzDecoder::new(w),
+ }
+ }
+
+ /// Returns the header associated with the current member.
+ pub fn header(&self) -> Option<&GzHeader> {
+ self.inner.header()
+ }
+
+ /// Acquires a reference to the underlying writer.
+ pub fn get_ref(&self) -> &W {
+ self.inner.get_ref()
+ }
+
+ /// Acquires a mutable reference to the underlying writer.
+ ///
+ /// Note that mutating the output/input state of the stream may corrupt this
+ /// object, so care must be taken when using this method.
+ pub fn get_mut(&mut self) -> &mut W {
+ self.inner.get_mut()
+ }
+
+ /// Attempt to finish this output stream, writing out final chunks of data.
+ ///
+ /// Note that this function can only be used once data has finished being
+ /// written to the output stream. After this function is called then further
+ /// calls to `write` may result in a panic.
+ ///
+ /// # Panics
+ ///
+ /// Attempts to write data to this stream may result in a panic after this
+ /// function is called.
+ ///
+ /// # Errors
+ ///
+ /// This function will perform I/O to finish the stream, returning any
+ /// errors which happen.
+ pub fn try_finish(&mut self) -> io::Result<()> {
+ self.inner.try_finish()
+ }
+
+ /// Consumes this decoder, flushing the output stream.
+ ///
+ /// This will flush the underlying data stream and then return the contained
+ /// writer if the flush succeeded.
+ ///
+ /// Note that this function may not be suitable to call in a situation where
+ /// the underlying stream is an asynchronous I/O stream. To finish a stream
+ /// the `try_finish` (or `shutdown`) method should be used instead. To
+ /// re-acquire ownership of a stream it is safe to call this method after
+ /// `try_finish` or `shutdown` has returned `Ok`.
+ ///
+ /// # Errors
+ ///
+ /// This function will perform I/O to complete this stream, and any I/O
+ /// errors which occur will be returned from this function.
+ pub fn finish(self) -> io::Result<W> {
+ self.inner.finish()
+ }
+}
+
+impl<W: Write> Write for MultiGzDecoder<W> {
+ fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
+ if buf.is_empty() {
+ Ok(0)
+ } else {
+ match self.inner.write(buf) {
+ Ok(0) => {
+ // When the GzDecoder indicates that it has finished
+ // create a new GzDecoder to handle additional data.
+ self.inner.try_finish()?;
+ let w = self.inner.inner.take_inner().into_inner();
+ self.inner = GzDecoder::new(w);
+ self.inner.write(buf)
+ }
+ res => res,
+ }
+ }
+ }
+
+ fn flush(&mut self) -> io::Result<()> {
+ self.inner.flush()
+ }
+}
+
#[cfg(test)]
mod tests {
use super::*;
- const STR: &'static str = "Hello World Hello World Hello World Hello World Hello World \
+ const STR: &str = "Hello World Hello World Hello World Hello World Hello World \
Hello World Hello World Hello World Hello World Hello World \
Hello World Hello World Hello World Hello World Hello World \
Hello World Hello World Hello World Hello World Hello World \
@@ -447,4 +553,26 @@ mod tests {
let return_string = String::from_utf8(writer).expect("String parsing error");
assert_eq!(return_string, STR);
}
+
+ // Two or more gzip files concatenated form a multi-member gzip file. MultiGzDecoder will
+ // concatenate the decoded contents of all members.
+ #[test]
+ fn decode_multi_writer() {
+ let mut e = GzEncoder::new(Vec::new(), Compression::default());
+ e.write(STR.as_ref()).unwrap();
+ let bytes = e.finish().unwrap().repeat(2);
+
+ let mut writer = Vec::new();
+ let mut decoder = MultiGzDecoder::new(writer);
+ let mut count = 0;
+ while count < bytes.len() {
+ let n = decoder.write(&bytes[count..]).unwrap();
+ assert!(n != 0);
+ count += n;
+ }
+ writer = decoder.finish().unwrap();
+ let return_string = String::from_utf8(writer).expect("String parsing error");
+ let expected = STR.repeat(2);
+ assert_eq!(return_string, expected);
+ }
}
diff --git a/vendor/flate2/src/lib.rs b/vendor/flate2/src/lib.rs
index 23a783e55..6789c5b76 100644
--- a/vendor/flate2/src/lib.rs
+++ b/vendor/flate2/src/lib.rs
@@ -76,6 +76,7 @@
#![deny(missing_debug_implementations)]
#![allow(trivial_numeric_casts)]
#![cfg_attr(test, deny(warnings))]
+#![cfg_attr(docsrs, feature(doc_auto_cfg))]
pub use crate::crc::{Crc, CrcReader, CrcWriter};
pub use crate::gz::GzBuilder;
@@ -115,6 +116,7 @@ pub mod write {
pub use crate::deflate::write::DeflateEncoder;
pub use crate::gz::write::GzDecoder;
pub use crate::gz::write::GzEncoder;
+ pub use crate::gz::write::MultiGzDecoder;
pub use crate::zlib::write::ZlibDecoder;
pub use crate::zlib::write::ZlibEncoder;
}
diff --git a/vendor/flate2/src/mem.rs b/vendor/flate2/src/mem.rs
index 5f1d6d8c1..6313c220d 100644
--- a/vendor/flate2/src/mem.rs
+++ b/vendor/flate2/src/mem.rs
@@ -40,9 +40,10 @@ pub struct Decompress {
inner: Inflate,
}
-#[derive(Copy, Clone, PartialEq, Eq, Debug)]
/// Values which indicate the form of flushing to be used when compressing
/// in-memory data.
+#[derive(Copy, Clone, PartialEq, Eq, Debug)]
+#[non_exhaustive]
pub enum FlushCompress {
/// A typical parameter for passing to compression/decompression functions,
/// this indicates that the underlying stream to decide how much data to
@@ -80,14 +81,12 @@ pub enum FlushCompress {
/// The return value may indicate that the stream is not yet done and more
/// data has yet to be processed.
Finish = ffi::MZ_FINISH as isize,
-
- #[doc(hidden)]
- _Nonexhaustive,
}
-#[derive(Copy, Clone, PartialEq, Eq, Debug)]
/// Values which indicate the form of flushing to be used when
/// decompressing in-memory data.
+#[derive(Copy, Clone, PartialEq, Eq, Debug)]
+#[non_exhaustive]
pub enum FlushDecompress {
/// A typical parameter for passing to compression/decompression functions,
/// this indicates that the underlying stream to decide how much data to
@@ -108,9 +107,6 @@ pub enum FlushDecompress {
/// The return value may indicate that the stream is not yet done and more
/// data has yet to be processed.
Finish = ffi::MZ_FINISH as isize,
-
- #[doc(hidden)]
- _Nonexhaustive,
}
/// The inner state for an error when decompressing
@@ -215,11 +211,6 @@ impl Compress {
///
/// If `window_bits` does not fall into the range 9 ..= 15,
/// `new_with_window_bits` will panic.
- ///
- /// # Note
- ///
- /// This constructor is only available when the `zlib` feature is used.
- /// Other backends currently do not support custom window bits.
#[cfg(feature = "any_zlib")]
pub fn new_with_window_bits(
level: Compression,
@@ -247,11 +238,6 @@ impl Compress {
///
/// If `window_bits` does not fall into the range 9 ..= 15,
/// `new_with_window_bits` will panic.
- ///
- /// # Note
- ///
- /// This constructor is only available when the `zlib` feature is used.
- /// Other backends currently do not support gzip headers for Compress.
#[cfg(feature = "any_zlib")]
pub fn new_gzip(level: Compression, window_bits: u8) -> Compress {
assert!(
@@ -362,7 +348,7 @@ impl Compress {
unsafe {
let before = self.total_out();
let ret = {
- let ptr = output.as_mut_ptr().offset(len as isize);
+ let ptr = output.as_mut_ptr().add(len);
let out = slice::from_raw_parts_mut(ptr, cap - len);
self.compress(input, out, flush)
};
@@ -393,11 +379,6 @@ impl Decompress {
///
/// If `window_bits` does not fall into the range 9 ..= 15,
/// `new_with_window_bits` will panic.
- ///
- /// # Note
- ///
- /// This constructor is only available when the `zlib` feature is used.
- /// Other backends currently do not support custom window bits.
#[cfg(feature = "any_zlib")]
pub fn new_with_window_bits(zlib_header: bool, window_bits: u8) -> Decompress {
assert!(
@@ -418,11 +399,6 @@ impl Decompress {
///
/// If `window_bits` does not fall into the range 9 ..= 15,
/// `new_with_window_bits` will panic.
- ///
- /// # Note
- ///
- /// This constructor is only available when the `zlib` feature is used.
- /// Other backends currently do not support gzip headers for Decompress.
#[cfg(feature = "any_zlib")]
pub fn new_gzip(window_bits: u8) -> Decompress {
assert!(
@@ -503,7 +479,7 @@ impl Decompress {
unsafe {
let before = self.total_out();
let ret = {
- let ptr = output.as_mut_ptr().offset(len as isize);
+ let ptr = output.as_mut_ptr().add(len);
let out = slice::from_raw_parts_mut(ptr, cap - len);
self.decompress(input, out, flush)
};
diff --git a/vendor/flate2/src/zio.rs b/vendor/flate2/src/zio.rs
index 50beacbd0..ea25922ab 100644
--- a/vendor/flate2/src/zio.rs
+++ b/vendor/flate2/src/zio.rs
@@ -143,10 +143,8 @@ where
// then we need to keep asking for more data because if we
// return that 0 bytes of data have been read then it will
// be interpreted as EOF.
- Ok(Status::Ok) | Ok(Status::BufError) if read == 0 && !eof && !dst.is_empty() => {
- continue
- }
- Ok(Status::Ok) | Ok(Status::BufError) | Ok(Status::StreamEnd) => return Ok(read),
+ Ok(Status::Ok | Status::BufError) if read == 0 && !eof && !dst.is_empty() => continue,
+ Ok(Status::Ok | Status::BufError | Status::StreamEnd) => return Ok(read),
Err(..) => {
return Err(io::Error::new(
diff --git a/vendor/flate2/src/zlib/bufread.rs b/vendor/flate2/src/zlib/bufread.rs
index f1d323165..61d12525c 100644
--- a/vendor/flate2/src/zlib/bufread.rs
+++ b/vendor/flate2/src/zlib/bufread.rs
@@ -192,7 +192,7 @@ impl<R> ZlibDecoder<R> {
/// Acquires a mutable reference to the underlying stream
///
/// Note that mutation of the stream may result in surprising results if
- /// this encoder is continued to be used.
+ /// this decoder is continued to be used.
pub fn get_mut(&mut self) -> &mut R {
&mut self.obj
}
diff --git a/vendor/flate2/src/zlib/mod.rs b/vendor/flate2/src/zlib/mod.rs
index 9d3de95c5..1a293ba08 100644
--- a/vendor/flate2/src/zlib/mod.rs
+++ b/vendor/flate2/src/zlib/mod.rs
@@ -19,14 +19,14 @@ mod tests {
let v = crate::random_bytes().take(1024).collect::<Vec<_>>();
for _ in 0..200 {
let to_write = &v[..thread_rng().gen_range(0..v.len())];
- real.extend(to_write.iter().map(|x| *x));
+ real.extend(to_write.iter().copied());
w.write_all(to_write).unwrap();
}
let result = w.finish().unwrap();
let mut r = read::ZlibDecoder::new(&result[..]);
let mut ret = Vec::new();
r.read_to_end(&mut ret).unwrap();
- assert!(ret == real);
+ assert_eq!(ret, real);
}
#[test]
@@ -38,7 +38,7 @@ mod tests {
let mut r = read::ZlibDecoder::new(&data[..]);
let mut ret = Vec::new();
r.read_to_end(&mut ret).unwrap();
- assert!(ret == b"foo");
+ assert_eq!(ret, b"foo");
}
#[test]
@@ -48,7 +48,7 @@ mod tests {
let v = crate::random_bytes().take(1024).collect::<Vec<_>>();
for _ in 0..200 {
let to_write = &v[..thread_rng().gen_range(0..v.len())];
- real.extend(to_write.iter().map(|x| *x));
+ real.extend(to_write.iter().copied());
w.write_all(to_write).unwrap();
}
let mut result = w.finish().unwrap();
@@ -56,13 +56,13 @@ mod tests {
let result_len = result.len();
for _ in 0..200 {
- result.extend(v.iter().map(|x| *x));
+ result.extend(v.iter().copied());
}
let mut r = read::ZlibDecoder::new(&result[..]);
let mut ret = Vec::new();
r.read_to_end(&mut ret).unwrap();
- assert!(ret == real);
+ assert_eq!(ret, real);
assert_eq!(r.total_in(), result_len as u64);
}
@@ -82,7 +82,7 @@ mod tests {
write::ZlibEncoder::new(write::ZlibDecoder::new(Vec::new()), Compression::default());
w.write_all(&v).unwrap();
let w = w.finish().unwrap().finish().unwrap();
- assert!(w == v);
+ assert_eq!(w, v);
}
#[test]
diff --git a/vendor/flate2/src/zlib/read.rs b/vendor/flate2/src/zlib/read.rs
index 509493166..330213049 100644
--- a/vendor/flate2/src/zlib/read.rs
+++ b/vendor/flate2/src/zlib/read.rs
@@ -195,7 +195,7 @@ impl<R> ZlibDecoder<R> {
/// Acquires a mutable reference to the underlying stream
///
/// Note that mutation of the stream may result in surprising results if
- /// this encoder is continued to be used.
+ /// this decoder is continued to be used.
pub fn get_mut(&mut self) -> &mut R {
self.inner.get_mut().get_mut()
}