diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
commit | dc0db358abe19481e475e10c32149b53370f1a1c (patch) | |
tree | ab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/gix-features/src/zlib/stream/deflate | |
parent | Releasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-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/deflate')
-rw-r--r-- | vendor/gix-features/src/zlib/stream/deflate/mod.rs | 19 | ||||
-rw-r--r-- | vendor/gix-features/src/zlib/stream/deflate/tests.rs | 4 |
2 files changed, 20 insertions, 3 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()); |