Skip to content

Commit

Permalink
Apply many clippy fixes (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
donatello authored Jun 18, 2024
1 parent c80e4c4 commit b0d31e1
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ categories = ["api-bindings", "web-programming::http-client"]
[dependencies]
async-recursion = "1.0.4"
async-trait = "0.1.73"
base64 = "0.21.3"
base64 = "0.22"
byteorder = "1.4.3"
bytes = "1.4.0"
chrono = "0.4.27"
Expand Down
10 changes: 6 additions & 4 deletions src/s3/builders/list_objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl ToStream for ListObjectsV1 {
let resp = args.send().await;
match resp {
Ok(resp) => {
args.marker = resp.next_marker.clone();
args.marker.clone_from(&resp.next_marker);
is_done = !resp.is_truncated;
Some((Ok(resp), (args, is_done)))
}
Expand Down Expand Up @@ -249,7 +249,8 @@ impl ToStream for ListObjectsV2 {
let resp = args.send().await;
match resp {
Ok(resp) => {
args.continuation_token = resp.next_continuation_token.clone();
args.continuation_token
.clone_from(&resp.next_continuation_token);
is_done = !resp.is_truncated;
Some((Ok(resp), (args, is_done)))
}
Expand Down Expand Up @@ -432,8 +433,9 @@ impl ToStream for ListObjectVersions {
let resp = args.send().await;
match resp {
Ok(resp) => {
args.key_marker = resp.next_key_marker.clone();
args.version_id_marker = resp.next_version_id_marker.clone();
args.key_marker.clone_from(&resp.next_key_marker);
args.version_id_marker
.clone_from(&resp.next_version_id_marker);

is_done = !resp.is_truncated;
Some((Ok(resp), (args, is_done)))
Expand Down
6 changes: 3 additions & 3 deletions src/s3/builders/put_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,11 +783,11 @@ impl PutObjectContent {
)));
}

let input_content = std::mem::replace(&mut self.input_content, ObjectContent::default());
let input_content = std::mem::take(&mut self.input_content);
self.content_stream = input_content
.to_content_stream()
.await
.map_err(|e| Error::IOError(e))?;
.map_err(Error::IOError)?;

// object_size may be Size::Unknown.
let object_size = self.content_stream.get_size();
Expand Down Expand Up @@ -1145,7 +1145,7 @@ mod tests {
if object_size < MIN_PART_SIZE {
return psize == object_size && part_count == 1;
}
if psize < MIN_PART_SIZE || psize > MAX_PART_SIZE{
if !(MIN_PART_SIZE..=MAX_PART_SIZE).contains(&psize){
return false;
}
if psize > object_size {
Expand Down
2 changes: 1 addition & 1 deletion src/s3/builders/remove_objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl ToS3Request for RemoveObjectsApi {
data.push_str("</Key>");
if let Some(v) = object.version_id.as_ref() {
data.push_str("<VersionId>");
data.push_str(&v);
data.push_str(v);
data.push_str("</VersionId>");
}
data.push_str("</Object>");
Expand Down
7 changes: 3 additions & 4 deletions src/s3/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ impl SelectObjectContentResponse {
self.prelude[i] = self
.buf
.pop_front()
.ok_or(Error::InsufficientData(8 as u64, i as u64))?;
.ok_or(Error::InsufficientData(8, i as u64))?;
}

Ok(true)
Expand All @@ -325,7 +325,7 @@ impl SelectObjectContentResponse {
self.prelude_crc[i] = self
.buf
.pop_front()
.ok_or(Error::InsufficientData(4 as u64, i as u64))?;
.ok_or(Error::InsufficientData(4, i as u64))?;
}

Ok(true)
Expand Down Expand Up @@ -361,7 +361,7 @@ impl SelectObjectContentResponse {
self.message_crc[i] = self
.buf
.pop_front()
.ok_or(Error::InsufficientData(4 as u64, i as u64))?;
.ok_or(Error::InsufficientData(4, i as u64))?;
}

Ok(true)
Expand All @@ -379,7 +379,6 @@ impl SelectObjectContentResponse {

let name = String::from_utf8(self.data[offset..offset + length].to_vec())?;
offset += length;

if self.data[offset] != 7 {
return Err(Error::InvalidHeaderValueType(self.data[offset]));
}
Expand Down
16 changes: 8 additions & 8 deletions src/s3/response/remove_objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,19 @@ impl FromS3Response for RemoveObjectsResponse {
.map(|elem| {
if elem.name == "Deleted" {
Ok(DeleteResult::Deleted(DeletedObject {
name: get_text(&elem, "Key")?,
version_id: get_option_text(&elem, "VersionId"),
delete_marker: get_default_text(&elem, "DeleteMarker").to_lowercase()
name: get_text(elem, "Key")?,
version_id: get_option_text(elem, "VersionId"),
delete_marker: get_default_text(elem, "DeleteMarker").to_lowercase()
== "true",
delete_marker_version_id: get_option_text(&elem, "DeleteMarkerVersionId"),
delete_marker_version_id: get_option_text(elem, "DeleteMarkerVersionId"),
}))
} else {
assert_eq!(elem.name, "Error");
Ok(DeleteResult::Error(DeleteError {
code: get_text(&elem, "Code")?,
message: get_text(&elem, "Message")?,
object_name: get_text(&elem, "Key")?,
version_id: get_option_text(&elem, "VersionId"),
code: get_text(elem, "Code")?,
message: get_text(elem, "Message")?,
object_name: get_text(elem, "Key")?,
version_id: get_option_text(elem, "VersionId"),
}))
}
})
Expand Down
6 changes: 3 additions & 3 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl ClientTest {
Error::S3Error(er) => {
assert_eq!(er.code, "NoSuchKey")
}
_ => assert!(false),
e => panic!("Unexpected error {:?}", e),
}
}

Expand Down Expand Up @@ -328,7 +328,7 @@ impl ClientTest {

async fn put_object_content(&self) {
let object_name = rand_object_name();
let sizes = vec![16_u64, 5 * 1024 * 1024, 16 + 5 * 1024 * 1024];
let sizes = [16_u64, 5 * 1024 * 1024, 16 + 5 * 1024 * 1024];

for size in sizes.iter() {
let data_src = RandSrc::new(*size);
Expand Down Expand Up @@ -793,7 +793,7 @@ impl ClientTest {
.unwrap();

let event_fn = |event: NotificationRecords| {
let record = event.records.iter().next();
let record = event.records.first();
if let Some(record) = record {
let key = &record.s3.object.key;
if name == *key {
Expand Down

0 comments on commit b0d31e1

Please sign in to comment.