Skip to content

Commit

Permalink
chore(async-compression): prepare release 0.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Nov 15, 2023
1 parent 37d106f commit 97fafc5
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 29 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "async-compression"
version = "0.4.4"
version = "0.4.5"
authors = ["Wim Looman <[email protected]>", "Allen Bui <[email protected]>"]
edition = "2018"
license = "MIT OR Apache-2.0"
Expand Down
20 changes: 10 additions & 10 deletions src/codec/xz2/decoder.rs
Original file line number Diff line number Diff line change
@@ -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()
}
}

Expand All @@ -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(())
}
Expand All @@ -32,7 +32,7 @@ impl Decode for Xz2Decoder {
&mut self,
input: &mut PartialBuffer<impl AsRef<[u8]>>,
output: &mut PartialBuffer<impl AsRef<[u8]> + AsMut<[u8]>>,
) -> Result<bool> {
) -> io::Result<bool> {
let previous_in = self.stream.total_in() as usize;
let previous_out = self.stream.total_out() as usize;

Expand All @@ -57,15 +57,15 @@ impl Decode for Xz2Decoder {
fn flush(
&mut self,
_output: &mut PartialBuffer<impl AsRef<[u8]> + AsMut<[u8]>>,
) -> Result<bool> {
) -> io::Result<bool> {
// While decoding flush is a noop
Ok(true)
}

fn finish(
&mut self,
output: &mut PartialBuffer<impl AsRef<[u8]> + AsMut<[u8]>>,
) -> Result<bool> {
) -> io::Result<bool> {
let previous_out = self.stream.total_out() as usize;

let status = self
Expand Down
22 changes: 12 additions & 10 deletions src/codec/xz2/encoder.rs
Original file line number Diff line number Diff line change
@@ -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()
}
}

Expand All @@ -33,7 +35,7 @@ impl Encode for Xz2Encoder {
&mut self,
input: &mut PartialBuffer<impl AsRef<[u8]>>,
output: &mut PartialBuffer<impl AsRef<[u8]> + AsMut<[u8]>>,
) -> Result<()> {
) -> io::Result<()> {
let previous_in = self.stream.total_in() as usize;
let previous_out = self.stream.total_out() as usize;

Expand All @@ -57,7 +59,7 @@ impl Encode for Xz2Encoder {
fn flush(
&mut self,
output: &mut PartialBuffer<impl AsRef<[u8]> + AsMut<[u8]>>,
) -> Result<bool> {
) -> io::Result<bool> {
let previous_out = self.stream.total_out() as usize;

let status = self
Expand All @@ -80,7 +82,7 @@ impl Encode for Xz2Encoder {
fn finish(
&mut self,
output: &mut PartialBuffer<impl AsRef<[u8]> + AsMut<[u8]>>,
) -> Result<bool> {
) -> io::Result<bool> {
let previous_out = self.stream.total_out() as usize;

let status = self
Expand Down
20 changes: 12 additions & 8 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 97fafc5

Please sign in to comment.