more clippy fixes and/or whitelists
Some checks failed
Rust / build (pull_request) Failing after 1m5s
Some checks failed
Rust / build (pull_request) Failing after 1m5s
This commit is contained in:
parent
61f83a7042
commit
ff886ca27d
3 changed files with 36 additions and 20 deletions
|
|
@ -85,6 +85,8 @@ module_name_repetitions = "allow"
|
|||
missing_errors_doc = "allow"
|
||||
# The few places where a panic is triggered in code are inspected and should never panic
|
||||
missing_panics_doc = "allow"
|
||||
# Does not work for all types, but should probably be fixed at some point
|
||||
iter_without_into_iter = "allow"
|
||||
|
||||
[lints.rustdoc]
|
||||
private_doc_tests = "warn"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
#[allow(unused)]
|
||||
use std::io::{Read, Write};
|
||||
|
||||
#[cfg(feature = "compression_bzip2")]
|
||||
use bzip2::read::{BzDecoder, BzEncoder};
|
||||
#[cfg(feature = "compression_zlib")]
|
||||
use flate2::{FlushCompress, FlushDecompress, Status};
|
||||
use log::error;
|
||||
#[allow(unused)]
|
||||
use std::io::{Read, Write};
|
||||
#[cfg(feature = "compression_zstd")]
|
||||
use zstd::{Decoder as ZstdDecoder, Encoder as ZstdEncoder};
|
||||
|
||||
|
|
@ -22,21 +21,31 @@ pub(crate) fn into_decompressed(
|
|||
let mut decompress = flate2::Decompress::new(true);
|
||||
let mut buffer = [0u8; 10000];
|
||||
|
||||
let status = match decompress.decompress(
|
||||
match decompress.decompress(
|
||||
&payload,
|
||||
&mut buffer,
|
||||
FlushDecompress::Finish,
|
||||
) {
|
||||
Err(_) => return None,
|
||||
Ok(status) => status,
|
||||
};
|
||||
|
||||
match status {
|
||||
Status::Ok => None,
|
||||
Status::BufError => None,
|
||||
Status::StreamEnd => Some(
|
||||
buffer[0..(decompress.total_out() as usize)].to_owned(),
|
||||
),
|
||||
Ok(Status::Ok) => {
|
||||
error!("input not big enough");
|
||||
None
|
||||
}
|
||||
Ok(Status::BufError) => {
|
||||
error!("output buffer is too small");
|
||||
None
|
||||
}
|
||||
Ok(Status::StreamEnd) =>
|
||||
{
|
||||
#[allow(
|
||||
clippy::cast_possible_truncation,
|
||||
reason = "can never be larger than the fixed buffer size"
|
||||
)]
|
||||
Some(buffer[..decompress.total_out() as usize].to_owned())
|
||||
}
|
||||
Err(e) => {
|
||||
error!("compress returned err: {e}");
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "compression_bzip2")]
|
||||
|
|
@ -86,18 +95,23 @@ pub(crate) fn into_compressed(
|
|||
FlushCompress::Finish,
|
||||
) {
|
||||
Ok(Status::Ok) => {
|
||||
error!("buffer not big enough");
|
||||
error!("output buffer not big enough");
|
||||
None
|
||||
}
|
||||
Ok(Status::BufError) => {
|
||||
error!("Could not compress: {:?}", Status::BufError);
|
||||
error!("Could not compress with buffer error");
|
||||
None
|
||||
}
|
||||
Ok(Status::StreamEnd) => {
|
||||
Ok(Status::StreamEnd) =>
|
||||
{
|
||||
#[allow(
|
||||
clippy::cast_possible_truncation,
|
||||
reason = "can never be larger than the fixed buffer size"
|
||||
)]
|
||||
Some(buffer[..compress.total_out() as usize].to_owned())
|
||||
}
|
||||
Err(_) => {
|
||||
error!("compress returned err");
|
||||
Err(e) => {
|
||||
error!("compress returned err: {e}");
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ impl Connection for WebsocketConnection {
|
|||
.try_into()
|
||||
.map(Into::<Vec<u8>>::into)
|
||||
.map_err(SendError::IntoPacket)?;
|
||||
#[allow(clippy::unwrap)]
|
||||
#[allow(clippy::unwrap_used)]
|
||||
let mut socket = self.0.lock().unwrap();
|
||||
socket
|
||||
.send(tungstenite::Message::Binary(data.into()))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue