Skip to content

Commit 4c6ae38

Browse files
authored
Merge pull request #253 from Nullus157/rel-045
prepare release 0.4.5
2 parents 37d106f + 97fafc5 commit 4c6ae38

File tree

5 files changed

+39
-29
lines changed

5 files changed

+39
-29
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0),
66

77
## Unreleased
88

9+
## 0.4.5
10+
11+
- Add `{Lzma, Xz}Decoder::with_mem_limit()` methods.
12+
913
## 0.4.4
1014

1115
- Update `zstd` dependency to `0.13`.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "async-compression"
3-
version = "0.4.4"
3+
version = "0.4.5"
44
authors = ["Wim Looman <[email protected]>", "Allen Bui <[email protected]>"]
55
edition = "2018"
66
license = "MIT OR Apache-2.0"

src/codec/xz2/decoder.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
use crate::{codec::Decode, util::PartialBuffer};
1+
use std::{fmt, io};
22

3-
use std::fmt::{Debug, Formatter, Result as FmtResult};
4-
use std::io::Result;
53
use xz2::stream::{Action, Status, Stream};
64

5+
use crate::{codec::Decode, util::PartialBuffer};
6+
77
pub struct Xz2Decoder {
88
stream: Stream,
99
}
1010

11-
impl Debug for Xz2Decoder {
12-
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
13-
write!(f, "LzmaDecoder")
11+
impl fmt::Debug for Xz2Decoder {
12+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13+
f.debug_struct("Xz2Decoder").finish_non_exhaustive()
1414
}
1515
}
1616

@@ -23,7 +23,7 @@ impl Xz2Decoder {
2323
}
2424

2525
impl Decode for Xz2Decoder {
26-
fn reinit(&mut self) -> Result<()> {
26+
fn reinit(&mut self) -> io::Result<()> {
2727
*self = Self::new(self.stream.memlimit());
2828
Ok(())
2929
}
@@ -32,7 +32,7 @@ impl Decode for Xz2Decoder {
3232
&mut self,
3333
input: &mut PartialBuffer<impl AsRef<[u8]>>,
3434
output: &mut PartialBuffer<impl AsRef<[u8]> + AsMut<[u8]>>,
35-
) -> Result<bool> {
35+
) -> io::Result<bool> {
3636
let previous_in = self.stream.total_in() as usize;
3737
let previous_out = self.stream.total_out() as usize;
3838

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

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

7171
let status = self

src/codec/xz2/encoder.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
use crate::codec::Xz2FileFormat;
2-
use crate::{codec::Encode, util::PartialBuffer};
1+
use std::{fmt, io};
32

4-
use std::fmt::{Debug, Formatter, Result as FmtResult};
5-
use std::io::Result;
63
use xz2::stream::{Action, Check, LzmaOptions, Status, Stream};
74

5+
use crate::{
6+
codec::{Encode, Xz2FileFormat},
7+
util::PartialBuffer,
8+
};
9+
810
pub struct Xz2Encoder {
911
stream: Stream,
1012
}
1113

12-
impl Debug for Xz2Encoder {
13-
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
14-
write!(f, "Xz2Encoder")
14+
impl fmt::Debug for Xz2Encoder {
15+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16+
f.debug_struct("Xz2Encoder").finish_non_exhaustive()
1517
}
1618
}
1719

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

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

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

8688
let status = self

src/macros.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,12 @@ macro_rules! algos {
223223
}
224224
}
225225
{ @dec
226-
/// Creates a new decoder, using the specified limit of memory. `Err(Custom { kind:
227-
/// Other, error: MemLimit })` can be returned during decoding if the specified limit
228-
/// is too small.
229-
pub fn with_memlimit(read: $inner, memlimit: u64) -> Self {
226+
/// Creates a new decoder with the specified limit of memory.
227+
///
228+
/// # Errors
229+
///
230+
/// An IO error may be returned during decoding if the specified limit is too small.
231+
pub fn with_mem_limit(read: $inner, memlimit: u64) -> Self {
230232
Self {
231233
inner: crate::$($mod::)+generic::Decoder::new(
232234
read,
@@ -250,10 +252,12 @@ macro_rules! algos {
250252
}
251253
}
252254
{ @dec
253-
/// Creates a new decoder, using the specified limit of memory. `Err(Custom { kind:
254-
/// Other, error: MemLimit })` can be returned during decoding if the specified limit
255-
/// is too small.
256-
pub fn with_memlimit(read: $inner, memlimit: u64) -> Self {
255+
/// Creates a new decoder with the specified limit of memory.
256+
///
257+
/// # Errors
258+
///
259+
/// An IO error may be returned during decoding if the specified limit is too small.
260+
pub fn with_mem_limit(read: $inner, memlimit: u64) -> Self {
257261
Self {
258262
inner: crate::$($mod::)+generic::Decoder::new(
259263
read,

0 commit comments

Comments
 (0)