From 97fafc5e7be675f6476acbe342d68133ec39d9b0 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 15 Nov 2023 02:55:06 +0000 Subject: [PATCH] chore(async-compression): prepare release 0.4.5 --- CHANGELOG.md | 4 ++++ Cargo.toml | 2 +- src/codec/xz2/decoder.rs | 20 ++++++++++---------- src/codec/xz2/encoder.rs | 22 ++++++++++++---------- src/macros.rs | 20 ++++++++++++-------- 5 files changed, 39 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de70e861..9d8152b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0), ## Unreleased +## 0.4.5 + +- Add `{Lzma, Xz}Decoder::with_mem_limit()` methods. + ## 0.4.4 - Update `zstd` dependency to `0.13`. diff --git a/Cargo.toml b/Cargo.toml index 17e8b45d..84ebefaa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-compression" -version = "0.4.4" +version = "0.4.5" authors = ["Wim Looman ", "Allen Bui "] edition = "2018" license = "MIT OR Apache-2.0" diff --git a/src/codec/xz2/decoder.rs b/src/codec/xz2/decoder.rs index 5c7f7fbf..b93203ff 100644 --- a/src/codec/xz2/decoder.rs +++ b/src/codec/xz2/decoder.rs @@ -1,16 +1,16 @@ -use crate::{codec::Decode, util::PartialBuffer}; +use std::{fmt, io}; -use std::fmt::{Debug, Formatter, Result as FmtResult}; -use std::io::Result; use xz2::stream::{Action, Status, Stream}; +use crate::{codec::Decode, util::PartialBuffer}; + pub struct Xz2Decoder { stream: Stream, } -impl Debug for Xz2Decoder { - fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { - write!(f, "LzmaDecoder") +impl fmt::Debug for Xz2Decoder { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Xz2Decoder").finish_non_exhaustive() } } @@ -23,7 +23,7 @@ impl Xz2Decoder { } impl Decode for Xz2Decoder { - fn reinit(&mut self) -> Result<()> { + fn reinit(&mut self) -> io::Result<()> { *self = Self::new(self.stream.memlimit()); Ok(()) } @@ -32,7 +32,7 @@ impl Decode for Xz2Decoder { &mut self, input: &mut PartialBuffer>, output: &mut PartialBuffer + AsMut<[u8]>>, - ) -> Result { + ) -> io::Result { let previous_in = self.stream.total_in() as usize; let previous_out = self.stream.total_out() as usize; @@ -57,7 +57,7 @@ impl Decode for Xz2Decoder { fn flush( &mut self, _output: &mut PartialBuffer + AsMut<[u8]>>, - ) -> Result { + ) -> io::Result { // While decoding flush is a noop Ok(true) } @@ -65,7 +65,7 @@ impl Decode for Xz2Decoder { fn finish( &mut self, output: &mut PartialBuffer + AsMut<[u8]>>, - ) -> Result { + ) -> io::Result { let previous_out = self.stream.total_out() as usize; let status = self diff --git a/src/codec/xz2/encoder.rs b/src/codec/xz2/encoder.rs index d5e29863..443c41b0 100644 --- a/src/codec/xz2/encoder.rs +++ b/src/codec/xz2/encoder.rs @@ -1,17 +1,19 @@ -use crate::codec::Xz2FileFormat; -use crate::{codec::Encode, util::PartialBuffer}; +use std::{fmt, io}; -use std::fmt::{Debug, Formatter, Result as FmtResult}; -use std::io::Result; use xz2::stream::{Action, Check, LzmaOptions, Status, Stream}; +use crate::{ + codec::{Encode, Xz2FileFormat}, + util::PartialBuffer, +}; + pub struct Xz2Encoder { stream: Stream, } -impl Debug for Xz2Encoder { - fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { - write!(f, "Xz2Encoder") +impl fmt::Debug for Xz2Encoder { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Xz2Encoder").finish_non_exhaustive() } } @@ -33,7 +35,7 @@ impl Encode for Xz2Encoder { &mut self, input: &mut PartialBuffer>, output: &mut PartialBuffer + AsMut<[u8]>>, - ) -> Result<()> { + ) -> io::Result<()> { let previous_in = self.stream.total_in() as usize; let previous_out = self.stream.total_out() as usize; @@ -57,7 +59,7 @@ impl Encode for Xz2Encoder { fn flush( &mut self, output: &mut PartialBuffer + AsMut<[u8]>>, - ) -> Result { + ) -> io::Result { let previous_out = self.stream.total_out() as usize; let status = self @@ -80,7 +82,7 @@ impl Encode for Xz2Encoder { fn finish( &mut self, output: &mut PartialBuffer + AsMut<[u8]>>, - ) -> Result { + ) -> io::Result { let previous_out = self.stream.total_out() as usize; let status = self diff --git a/src/macros.rs b/src/macros.rs index 027dcc3b..8965b651 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -223,10 +223,12 @@ macro_rules! algos { } } { @dec - /// Creates a new decoder, using the specified limit of memory. `Err(Custom { kind: - /// Other, error: MemLimit })` can be returned during decoding if the specified limit - /// is too small. - pub fn with_memlimit(read: $inner, memlimit: u64) -> Self { + /// Creates a new decoder with the specified limit of memory. + /// + /// # Errors + /// + /// An IO error may be returned during decoding if the specified limit is too small. + pub fn with_mem_limit(read: $inner, memlimit: u64) -> Self { Self { inner: crate::$($mod::)+generic::Decoder::new( read, @@ -250,10 +252,12 @@ macro_rules! algos { } } { @dec - /// Creates a new decoder, using the specified limit of memory. `Err(Custom { kind: - /// Other, error: MemLimit })` can be returned during decoding if the specified limit - /// is too small. - pub fn with_memlimit(read: $inner, memlimit: u64) -> Self { + /// Creates a new decoder with the specified limit of memory. + /// + /// # Errors + /// + /// An IO error may be returned during decoding if the specified limit is too small. + pub fn with_mem_limit(read: $inner, memlimit: u64) -> Self { Self { inner: crate::$($mod::)+generic::Decoder::new( read,