Skip to content

Commit 2337518

Browse files
committed
chore: Cargo clippy fixes and cargo fmt
1 parent 1df38c4 commit 2337518

3 files changed

Lines changed: 22 additions & 29 deletions

File tree

crates/pithos_lib/src/lib.rs

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -696,9 +696,8 @@ mod tests {
696696
let stream1 = tokio_util::io::ReaderStream::new(file1);
697697
let stream2 = tokio_util::io::ReaderStream::new(file2);
698698
let chained = stream1.chain(stream2);
699-
let mapped = chained.map_err(|_| {
700-
Box::<(dyn std::error::Error + Send + Sync + 'static)>::from("a_str_error")
701-
});
699+
let mapped = chained
700+
.map_err(|_| Box::<dyn std::error::Error + Send + Sync + 'static>::from("a_str_error"));
702701

703702
// File context input
704703
let (sx, rx) = async_channel::bounded(10);
@@ -741,9 +740,8 @@ mod tests {
741740
let stream1 = tokio_util::io::ReaderStream::new(file1);
742741
let stream2 = tokio_util::io::ReaderStream::new(file2);
743742
let chained = stream1.chain(stream2);
744-
let mapped = chained.map_err(|_| {
745-
Box::<(dyn std::error::Error + Send + Sync + 'static)>::from("a_str_error")
746-
});
743+
let mapped = chained
744+
.map_err(|_| Box::<dyn std::error::Error + Send + Sync + 'static>::from("a_str_error"));
747745

748746
let (sx, rx) = async_channel::bounded(10);
749747
sx.send(Message::FileContext(FileContext {
@@ -819,9 +817,8 @@ mod tests {
819817
let stream1 = tokio_util::io::ReaderStream::new(file1);
820818
let stream2 = tokio_util::io::ReaderStream::new(file2);
821819
let chained = stream1.chain(stream2);
822-
let mapped = chained.map_err(|_| {
823-
Box::<(dyn std::error::Error + Send + Sync + 'static)>::from("a_str_error")
824-
});
820+
let mapped = chained
821+
.map_err(|_| Box::<dyn std::error::Error + Send + Sync + 'static>::from("a_str_error"));
825822

826823
// File context input
827824
let (sx, rx) = async_channel::bounded(10);
@@ -885,9 +882,8 @@ mod tests {
885882
let stream1 = tokio_util::io::ReaderStream::new(file1);
886883
let stream2 = tokio_util::io::ReaderStream::new(file2);
887884
let chained = stream1.chain(stream2);
888-
let mapped = chained.map_err(|_| {
889-
Box::<(dyn std::error::Error + Send + Sync + 'static)>::from("a_str_error")
890-
});
885+
let mapped = chained
886+
.map_err(|_| Box::<dyn std::error::Error + Send + Sync + 'static>::from("a_str_error"));
891887

892888
// File context input
893889
let (sx, rx) = async_channel::bounded(10);
@@ -1004,9 +1000,8 @@ mod tests {
10041000
.unwrap_or_default();
10051001

10061002
let mut tar_gz_file = File::create(&tar_gz_out_path).await.unwrap();
1007-
let read_stream = tokio_util::io::ReaderStream::new(pithos_in).map_err(|_| {
1008-
Box::<(dyn std::error::Error + Send + Sync + 'static)>::from("a_str_error")
1009-
});
1003+
let read_stream = tokio_util::io::ReaderStream::new(pithos_in)
1004+
.map_err(|_| Box::<dyn std::error::Error + Send + Sync + 'static>::from("a_str_error"));
10101005

10111006
let (sx2, rx2) = async_channel::bounded(10);
10121007
let mut reader = GenericStreamReadWriter::new_with_writer(read_stream, &mut tar_gz_file)
@@ -1038,9 +1033,8 @@ mod tests {
10381033

10391034
let input_file = File::open("test.txt").await.unwrap();
10401035
let input_size = input_file.metadata().await.unwrap().len();
1041-
let input_stream = tokio_util::io::ReaderStream::new(input_file).map_err(|_| {
1042-
Box::<(dyn std::error::Error + Send + Sync + 'static)>::from("a_str_error")
1043-
});
1036+
let input_stream = tokio_util::io::ReaderStream::new(input_file)
1037+
.map_err(|_| Box::<dyn std::error::Error + Send + Sync + 'static>::from("a_str_error"));
10441038

10451039
// File context input
10461040
let privkey_bytes = BASE64_STANDARD
@@ -1126,9 +1120,8 @@ mod tests {
11261120

11271121
// Create reader stream for Pithos file
11281122
pithos_input.seek(SeekFrom::Start(0)).await.unwrap();
1129-
let read_stream = tokio_util::io::ReaderStream::new(pithos_input).map_err(|_| {
1130-
Box::<(dyn std::error::Error + Send + Sync + 'static)>::from("a_str_error")
1131-
});
1123+
let read_stream = tokio_util::io::ReaderStream::new(pithos_input)
1124+
.map_err(|_| Box::<dyn std::error::Error + Send + Sync + 'static>::from("a_str_error"));
11321125

11331126
let privkey_bytes_2 = BASE64_STANDARD
11341127
.decode("MC4CAQAwBQYDK2VuBCIEIMhHHRAu72qdkx9I4D08RD3OQniJxGUI420aPlZwAJtX")
@@ -1188,9 +1181,8 @@ mod tests {
11881181

11891182
let input_file = File::open("test.txt").await.unwrap();
11901183
let input_size = input_file.metadata().await.unwrap().len();
1191-
let input_stream = tokio_util::io::ReaderStream::new(input_file).map_err(|_| {
1192-
Box::<(dyn std::error::Error + Send + Sync + 'static)>::from("a_str_error")
1193-
});
1184+
let input_stream = tokio_util::io::ReaderStream::new(input_file)
1185+
.map_err(|_| Box::<dyn std::error::Error + Send + Sync + 'static>::from("a_str_error"));
11941186

11951187
// File context input
11961188
let privkey_bytes = BASE64_STANDARD
@@ -1262,9 +1254,8 @@ mod tests {
12621254
// Read footer with FooterExtractor
12631255
let mut vec = Vec::new();
12641256
pithos_input.seek(SeekFrom::Start(0)).await.unwrap();
1265-
let input_stream = tokio_util::io::ReaderStream::new(pithos_input).map_err(|_| {
1266-
Box::<(dyn std::error::Error + Send + Sync + 'static)>::from("a_str_error")
1267-
});
1257+
let input_stream = tokio_util::io::ReaderStream::new(pithos_input)
1258+
.map_err(|_| Box::<dyn std::error::Error + Send + Sync + 'static>::from("a_str_error"));
12681259

12691260
let (extractor, rcv) = FooterExtractor::new(Some(privkey));
12701261
GenericStreamReadWriter::new_with_writer(input_stream, &mut vec)

crates/pithos_lib/src/readwrite.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ impl<'a, R: AsyncRead + Unpin + Send + Sync> ReadWriter for GenericReadWriter<'a
212212
if let Some(context) = &file_ctx {
213213
self.size_counter += read_bytes;
214214
if self.size_counter > context.compressed_size as usize {
215-
let mut diff = read_buf.len()
215+
let mut diff = read_buf
216+
.len()
216217
.saturating_sub(self.size_counter - context.compressed_size as usize);
217218
if diff >= context.compressed_size as usize {
218219
diff = context.compressed_size as usize

crates/pithos_lib/src/streamreadwrite.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ impl<
246246
if let Some(context) = &file_ctx {
247247
self.size_counter += read_bytes;
248248
if self.size_counter > context.compressed_size as usize {
249-
let mut diff = read_buf.len()
249+
let mut diff = read_buf
250+
.len()
250251
.saturating_sub(self.size_counter - context.compressed_size as usize);
251252
if diff >= context.compressed_size as usize {
252253
diff = context.compressed_size as usize

0 commit comments

Comments
 (0)