Skip to content

Commit

Permalink
Merge pull request #253 from Nullus157/rel-045
Browse files Browse the repository at this point in the history
prepare release 0.4.5
  • Loading branch information
robjtede committed Nov 15, 2023
2 parents 37d106f + 97fafc5 commit 4c6ae38
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 29 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
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
@@ -1,6 +1,6 @@
[package]
name = "async-compression"
version = "0.4.4"
version = "0.4.5"
authors = ["Wim Looman <wim@nemo157.com>", "Allen Bui <fairingrey@gmail.com>"]
edition = "2018"
license = "MIT OR Apache-2.0"
Expand Down
20 changes: 10 additions & 10 deletions 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()
}
}

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
@@ -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
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 4c6ae38

Please sign in to comment.