summaryrefslogtreecommitdiffstats
path: root/vendor/gix-features/src/zlib/stream
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/gix-features/src/zlib/stream
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/gix-features/src/zlib/stream')
-rw-r--r--vendor/gix-features/src/zlib/stream/deflate/mod.rs19
-rw-r--r--vendor/gix-features/src/zlib/stream/deflate/tests.rs4
-rw-r--r--vendor/gix-features/src/zlib/stream/inflate.rs6
3 files changed, 23 insertions, 6 deletions
diff --git a/vendor/gix-features/src/zlib/stream/deflate/mod.rs b/vendor/gix-features/src/zlib/stream/deflate/mod.rs
index 55f575ea4..567e8fece 100644
--- a/vendor/gix-features/src/zlib/stream/deflate/mod.rs
+++ b/vendor/gix-features/src/zlib/stream/deflate/mod.rs
@@ -11,6 +11,19 @@ pub struct Write<W> {
buf: [u8; BUF_SIZE],
}
+impl<W> Clone for Write<W>
+where
+ W: Clone,
+{
+ fn clone(&self) -> Self {
+ Write {
+ compressor: impls::new_compress(),
+ inner: self.inner.clone(),
+ buf: self.buf,
+ }
+ }
+}
+
mod impls {
use std::io;
@@ -18,6 +31,10 @@ mod impls {
use crate::zlib::stream::deflate;
+ pub(crate) fn new_compress() -> Compress {
+ Compress::new(Compression::fast(), true)
+ }
+
impl<W> deflate::Write<W>
where
W: io::Write,
@@ -25,7 +42,7 @@ mod impls {
/// Create a new instance writing compressed bytes to `inner`.
pub fn new(inner: W) -> deflate::Write<W> {
deflate::Write {
- compressor: Compress::new(Compression::fast(), true),
+ compressor: new_compress(),
inner,
buf: [0; deflate::BUF_SIZE],
}
diff --git a/vendor/gix-features/src/zlib/stream/deflate/tests.rs b/vendor/gix-features/src/zlib/stream/deflate/tests.rs
index ba0dd2a2c..7c5865e0b 100644
--- a/vendor/gix-features/src/zlib/stream/deflate/tests.rs
+++ b/vendor/gix-features/src/zlib/stream/deflate/tests.rs
@@ -75,7 +75,7 @@ mod deflate_stream {
fn big_file_small_writes() -> Result<(), Box<dyn std::error::Error>> {
let mut w = deflate::Write::new(Vec::new());
let bytes = include_bytes!(
- "../../../../tests/fixtures/objects/pack/pack-11fdfa9e156ab73caae3b6da867192221f2089c2.pack"
+ "../../../../../gix-odb/tests/fixtures/objects/pack/pack-11fdfa9e156ab73caae3b6da867192221f2089c2.pack"
);
for chunk in bytes.chunks(2) {
assert_eq!(w.write(chunk)?, chunk.len());
@@ -89,7 +89,7 @@ mod deflate_stream {
fn big_file_a_few_big_writes() -> Result<(), Box<dyn std::error::Error>> {
let mut w = deflate::Write::new(Vec::new());
let bytes = include_bytes!(
- "../../../../tests/fixtures/objects/pack/pack-11fdfa9e156ab73caae3b6da867192221f2089c2.pack"
+ "../../../../../gix-odb/tests/fixtures/objects/pack/pack-11fdfa9e156ab73caae3b6da867192221f2089c2.pack"
);
for chunk in bytes.chunks(4096 * 9) {
assert_eq!(w.write(chunk)?, chunk.len());
diff --git a/vendor/gix-features/src/zlib/stream/inflate.rs b/vendor/gix-features/src/zlib/stream/inflate.rs
index 007ecedc6..f68f45f57 100644
--- a/vendor/gix-features/src/zlib/stream/inflate.rs
+++ b/vendor/gix-features/src/zlib/stream/inflate.rs
@@ -46,11 +46,11 @@ pub fn read(rd: &mut impl BufRead, state: &mut Decompress, mut dst: &mut [u8]) -
// The stream has officially ended, nothing more to do here.
Ok(Status::StreamEnd) => return Ok(total_written),
// Either input our output are depleted even though the stream is not depleted yet.
- Ok(Status::Ok) | Ok(Status::BufError) if eof || dst.is_empty() => return Ok(total_written),
+ Ok(Status::Ok | Status::BufError) if eof || dst.is_empty() => return Ok(total_written),
// Some progress was made in both the input and the output, it must continue to reach the end.
- Ok(Status::Ok) | Ok(Status::BufError) if consumed != 0 || written != 0 => continue,
+ Ok(Status::Ok | Status::BufError) if consumed != 0 || written != 0 => continue,
// A strange state, where zlib makes no progress but isn't done either. Call it out.
- Ok(Status::Ok) | Ok(Status::BufError) => unreachable!("Definitely a bug somewhere"),
+ Ok(Status::Ok | Status::BufError) => unreachable!("Definitely a bug somewhere"),
Err(..) => return Err(io::Error::new(io::ErrorKind::InvalidInput, "corrupt deflate stream")),
}
}