Skip to content

Fix clippy error in async-compression #347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5ab7ecd
Fix clippy error in brotli decoder.rs
NobodyXu Jun 9, 2025
b8f73f6
Fix clippy error in brotli encoder.rs
NobodyXu Jun 9, 2025
5c6b3c0
Fix encoder.rs
NobodyXu Jun 9, 2025
7e6da26
Fix clippy error in bzip2 decoder.rs
NobodyXu Jun 9, 2025
abdacc9
Fix clippy error in flate decoder.rs
NobodyXu Jun 9, 2025
f4769ff
Fix clippy error in flate encoder.rs
NobodyXu Jun 9, 2025
b8b89bc
Fix clippy error in gzip header.rs
NobodyXu Jun 9, 2025
88c171b
Fix clippy error in gzip encoder.rs
NobodyXu Jun 9, 2025
3410595
Fix clippy error in gzip decoder.rs
NobodyXu Jun 9, 2025
12059f9
Fix clippy error in gzip encoder.rs
NobodyXu Jun 9, 2025
dc239cb
Fix clippy error in tokio generic decoder.rs
NobodyXu Jun 9, 2025
4882199
Fix clippy error in tokio generic encoder.rs
NobodyXu Jun 9, 2025
c175b91
Fix clippy error in future write generic decoder.rs
NobodyXu Jun 9, 2025
e4d68ef
Fix clippy error in futures write generic encoder.rs
NobodyXu Jun 9, 2025
9f16070
Fix doc link in lib.rs
NobodyXu Jun 9, 2025
381bf51
Fix clippy error in bzip2 decoder.rs
NobodyXu Jun 9, 2025
c20c334
Fix clippy error in bzip2 encoder.rs
NobodyXu Jun 9, 2025
5da6467
Fix clippy error in bzip2 encoder.rs
NobodyXu Jun 9, 2025
6149d57
Fix clippy error in xz2 decoder.rs
NobodyXu Jun 9, 2025
9c3b915
Fix clippy error in tokio/write/generic/decoder.rs
NobodyXu Jun 9, 2025
2834e8c
Fix fmt in brotli decoder.rs
NobodyXu Jun 9, 2025
cd0c04f
Fix fmt in xz2 decoder.rs
NobodyXu Jun 9, 2025
b0517cc
Fix clippy error and fmt in xz2 encoder.rs
NobodyXu Jun 9, 2025
5ea5bdf
Fix fmt in decoder.rs
NobodyXu Jun 9, 2025
6eeed32
Fix fmt in future write generics encoder.rs
NobodyXu Jun 9, 2025
a5059d7
Fix fmt in tokio write generics decoder.rs
NobodyXu Jun 9, 2025
71ead80
Fix fmt in tokio generics write encoder.rs
NobodyXu Jun 9, 2025
6569497
Fix tokio write generics decoder.rs
NobodyXu Jun 9, 2025
52d7d4c
Fix fmt in decoder.rs
NobodyXu Jun 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/codec/brotli/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ impl BrotliDecoder {
&mut 0,
&mut self.state,
) {
BrotliResult::ResultFailure => {
return Err(io::Error::new(io::ErrorKind::Other, "brotli error"))
}
BrotliResult::ResultFailure => return Err(io::Error::other("brotli error")),
status => status,
};

Expand Down
2 changes: 1 addition & 1 deletion src/codec/brotli/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl BrotliEncoder {
&mut None,
&mut |_, _, _, _| (),
) {
return Err(io::Error::new(io::ErrorKind::Other, "brotli error"));
return Err(io::Error::other("brotli error"));
}

input.advance(input_len);
Expand Down
4 changes: 2 additions & 2 deletions src/codec/bzip2/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl BzDecoder {
let status = self
.decompress
.decompress(input.unwritten(), output.unwritten_mut())
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
.map_err(io::Error::other)?;

input.advance((self.decompress.total_in() - prior_in) as usize);
output.advance((self.decompress.total_out() - prior_out) as usize);
Expand Down Expand Up @@ -74,7 +74,7 @@ impl Decode for BzDecoder {

// There was insufficient memory in the input or output buffer to complete
// the request, but otherwise everything went normally.
Status::MemNeeded => Err(io::Error::new(io::ErrorKind::Other, "out of memory")),
Status::MemNeeded => Err(io::Error::other("out of memory")),
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/codec/bzip2/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl BzEncoder {
let status = self
.compress
.compress(input.unwritten(), output.unwritten_mut(), action)
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
.map_err(io::Error::other)?;

input.advance((self.compress.total_in() - prior_in) as usize);
output.advance((self.compress.total_out() - prior_out) as usize);
Expand Down Expand Up @@ -90,7 +90,7 @@ impl Encode for BzEncoder {

// There was insufficient memory in the input or output buffer to complete
// the request, but otherwise everything went normally.
Status::MemNeeded => Err(io::Error::new(io::ErrorKind::Other, "out of memory")),
Status::MemNeeded => Err(io::Error::other("out of memory")),
}
}

Expand All @@ -116,7 +116,7 @@ impl Encode for BzEncoder {

// There was insufficient memory in the input or output buffer to complete
// the request, but otherwise everything went normally.
Status::MemNeeded => Err(io::Error::new(io::ErrorKind::Other, "out of memory")),
Status::MemNeeded => Err(io::Error::other("out of memory")),
}
}

Expand All @@ -142,7 +142,7 @@ impl Encode for BzEncoder {

// There was insufficient memory in the input or output buffer to complete
// the request, but otherwise everything went normally.
Status::MemNeeded => Err(io::Error::new(io::ErrorKind::Other, "out of memory")),
Status::MemNeeded => Err(io::Error::other("out of memory")),
}
}
}
4 changes: 2 additions & 2 deletions src/codec/flate/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Decode for FlateDecoder {
match self.decode(input, output, FlushDecompress::None)? {
Status::Ok => Ok(false),
Status::StreamEnd => Ok(true),
Status::BufError => Err(io::Error::new(io::ErrorKind::Other, "unexpected BufError")),
Status::BufError => Err(io::Error::other("unexpected BufError")),
}
}

Expand Down Expand Up @@ -91,7 +91,7 @@ impl Decode for FlateDecoder {
)? {
Status::Ok => Ok(false),
Status::StreamEnd => Ok(true),
Status::BufError => Err(io::Error::new(io::ErrorKind::Other, "unexpected BufError")),
Status::BufError => Err(io::Error::other("unexpected BufError")),
}
}
}
4 changes: 2 additions & 2 deletions src/codec/flate/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Encode for FlateEncoder {
match self.encode(input, output, FlushCompress::None)? {
Status::Ok => Ok(()),
Status::StreamEnd => unreachable!(),
Status::BufError => Err(io::Error::new(io::ErrorKind::Other, "unexpected BufError")),
Status::BufError => Err(io::Error::other("unexpected BufError")),
}
}

Expand Down Expand Up @@ -100,7 +100,7 @@ impl Encode for FlateEncoder {
)? {
Status::Ok => Ok(false),
Status::StreamEnd => Ok(true),
Status::BufError => Err(io::Error::new(io::ErrorKind::Other, "unexpected BufError")),
Status::BufError => Err(io::Error::other("unexpected BufError")),
}
}
}
5 changes: 1 addition & 4 deletions src/codec/gzip/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ impl Encode for GzipEncoder {
}

State::Footer(_) | State::Done => {
return Err(io::Error::new(
io::ErrorKind::Other,
"encode after complete",
));
return Err(io::Error::other("encode after complete"));
}
};

Expand Down
5 changes: 1 addition & 4 deletions src/codec/gzip/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@ impl Parser {
}

State::Done => {
return Err(io::Error::new(
io::ErrorKind::Other,
"parser used after done",
));
return Err(io::Error::other("parser used after done"));
}
};
}
Expand Down
14 changes: 4 additions & 10 deletions src/codec/xz2/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ impl Decode for Xz2Decoder {
match status {
Status::Ok => Ok(false),
Status::StreamEnd => Ok(true),
Status::GetCheck => Err(io::Error::new(
io::ErrorKind::Other,
"Unexpected lzma integrity check",
)),
Status::MemNeeded => Err(io::Error::new(io::ErrorKind::Other, "More memory needed")),
Status::GetCheck => Err(io::Error::other("Unexpected lzma integrity check")),
Status::MemNeeded => Err(io::Error::other("More memory needed")),
}
}

Expand All @@ -77,11 +74,8 @@ impl Decode for Xz2Decoder {
match status {
Status::Ok => Ok(false),
Status::StreamEnd => Ok(true),
Status::GetCheck => Err(io::Error::new(
io::ErrorKind::Other,
"Unexpected lzma integrity check",
)),
Status::MemNeeded => Err(io::Error::new(io::ErrorKind::Other, "More memory needed")),
Status::GetCheck => Err(io::Error::other("Unexpected lzma integrity check")),
Status::MemNeeded => Err(io::Error::other("More memory needed")),
}
}
}
21 changes: 6 additions & 15 deletions src/codec/xz2/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@ impl Encode for Xz2Encoder {

match status {
Status::Ok | Status::StreamEnd => Ok(()),
Status::GetCheck => Err(io::Error::new(
io::ErrorKind::Other,
"Unexpected lzma integrity check",
)),
Status::MemNeeded => Err(io::Error::new(io::ErrorKind::Other, "out of memory")),
Status::GetCheck => Err(io::Error::other("Unexpected lzma integrity check")),
Status::MemNeeded => Err(io::Error::other("out of memory")),
}
}

Expand All @@ -71,11 +68,8 @@ impl Encode for Xz2Encoder {
match status {
Status::Ok => Ok(false),
Status::StreamEnd => Ok(true),
Status::GetCheck => Err(io::Error::new(
io::ErrorKind::Other,
"Unexpected lzma integrity check",
)),
Status::MemNeeded => Err(io::Error::new(io::ErrorKind::Other, "out of memory")),
Status::GetCheck => Err(io::Error::other("Unexpected lzma integrity check")),
Status::MemNeeded => Err(io::Error::other("out of memory")),
}
}

Expand All @@ -94,11 +88,8 @@ impl Encode for Xz2Encoder {
match status {
Status::Ok => Ok(false),
Status::StreamEnd => Ok(true),
Status::GetCheck => Err(io::Error::new(
io::ErrorKind::Other,
"Unexpected lzma integrity check",
)),
Status::MemNeeded => Err(io::Error::new(io::ErrorKind::Other, "out of memory")),
Status::GetCheck => Err(io::Error::other("Unexpected lzma integrity check")),
Status::MemNeeded => Err(io::Error::other("out of memory")),
}
}
}
8 changes: 2 additions & 6 deletions src/futures/write/generic/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ impl<W: AsyncWrite, D: Decode> Decoder<W, D> {
}

State::Done => {
return Poll::Ready(Err(io::Error::new(
io::ErrorKind::Other,
"Write after end of stream",
)))
return Poll::Ready(Err(io::Error::other("Write after end of stream")))
}
};

Expand Down Expand Up @@ -179,8 +176,7 @@ impl<W: AsyncWrite, D: Decode> AsyncWrite for Decoder<W, D> {
ready!(self.as_mut().project().writer.as_mut().poll_close(cx))?;
Poll::Ready(Ok(()))
} else {
Poll::Ready(Err(io::Error::new(
io::ErrorKind::Other,
Poll::Ready(Err(io::Error::other(
"Attempt to close before finishing input",
)))
}
Expand Down
10 changes: 2 additions & 8 deletions src/futures/write/generic/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ impl<W: AsyncWrite, E: Encode> Encoder<W, E> {
}

State::Finishing | State::Done => {
return Poll::Ready(Err(io::Error::new(
io::ErrorKind::Other,
"Write after close",
)))
return Poll::Ready(Err(io::Error::other("Write after close")))
}
};

Expand All @@ -114,10 +111,7 @@ impl<W: AsyncWrite, E: Encode> Encoder<W, E> {
State::Encoding => this.encoder.flush(&mut output)?,

State::Finishing | State::Done => {
return Poll::Ready(Err(io::Error::new(
io::ErrorKind::Other,
"Flush after close",
)))
return Poll::Ready(Err(io::Error::other("Flush after close")))
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
#![allow(unexpected_cfgs)]
#![cfg_attr(
feature = "futures-io",
doc = "[`futures-io`](crate::futures) | [`futures::io::AsyncBufRead`](futures_io::AsyncBufRead), [`futures::io::AsyncWrite`](futures_io::AsyncWrite)"
doc = "[`futures-io`] | [`futures::io::AsyncBufRead`](futures_io::AsyncBufRead), [`futures::io::AsyncWrite`](futures_io::AsyncWrite)"
)]
#![cfg_attr(
not(feature = "futures-io"),
doc = "`futures-io` (*inactive*) | `futures::io::AsyncBufRead`, `futures::io::AsyncWrite`"
)]
#![cfg_attr(
feature = "tokio",
doc = "[`tokio`](crate::tokio) | [`tokio::io::AsyncBufRead`](::tokio::io::AsyncBufRead), [`tokio::io::AsyncWrite`](::tokio::io::AsyncWrite)"
doc = "[`tokio`] | [`tokio::io::AsyncBufRead`](::tokio::io::AsyncBufRead), [`tokio::io::AsyncWrite`](::tokio::io::AsyncWrite)"
)]
#![cfg_attr(
not(feature = "tokio"),
Expand Down
8 changes: 2 additions & 6 deletions src/tokio/write/generic/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ impl<W: AsyncWrite, D: Decode> Decoder<W, D> {
}

State::Done => {
return Poll::Ready(Err(io::Error::new(
io::ErrorKind::Other,
"Write after end of stream",
)))
return Poll::Ready(Err(io::Error::other("Write after end of stream")))
}
};

Expand Down Expand Up @@ -179,8 +176,7 @@ impl<W: AsyncWrite, D: Decode> AsyncWrite for Decoder<W, D> {
ready!(self.as_mut().project().writer.as_mut().poll_shutdown(cx))?;
Poll::Ready(Ok(()))
} else {
Poll::Ready(Err(io::Error::new(
io::ErrorKind::Other,
Poll::Ready(Err(io::Error::other(
"Attempt to shutdown before finishing input",
)))
}
Expand Down
10 changes: 2 additions & 8 deletions src/tokio/write/generic/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@ impl<W: AsyncWrite, E: Encode> Encoder<W, E> {
},

State::Finishing | State::Done => {
return Poll::Ready(Err(io::Error::new(
io::ErrorKind::Other,
"Write after shutdown",
)))
return Poll::Ready(Err(io::Error::other("Write after shutdown")))
}
};

Expand All @@ -123,10 +120,7 @@ impl<W: AsyncWrite, E: Encode> Encoder<W, E> {
State::Encoding | State::Flushing => this.encoder.flush(&mut output)?,

State::Finishing | State::Done => {
return Poll::Ready(Err(io::Error::new(
io::ErrorKind::Other,
"Flush after shutdown",
)))
return Poll::Ready(Err(io::Error::other("Flush after shutdown")))
}
};
*this.state = State::Flushing;
Expand Down