diff --git a/rust_dev_preview/examples/s3/src/bin/s3-multipart-upload.rs b/rust_dev_preview/examples/s3/src/bin/s3-multipart-upload.rs index 0b5384c3af2..59452b9ec9e 100644 --- a/rust_dev_preview/examples/s3/src/bin/s3-multipart-upload.rs +++ b/rust_dev_preview/examples/s3/src/bin/s3-multipart-upload.rs @@ -148,7 +148,11 @@ async fn run_example() -> Result<(), Error> { // snippet-end:[rust.example_code.s3.complete_multipart_upload] let data: GetObjectOutput = s3_service::download_object(&client, &bucket_name, &key).await?; - let data_length: u64 = data.content_length().try_into().unwrap(); + let data_length: u64 = data + .content_length() + .unwrap_or_default() + .try_into() + .unwrap(); if file.metadata().unwrap().len() == data_length { println!("Data lengths match."); } else { diff --git a/rust_dev_preview/examples/s3/src/s3-service-lib.rs b/rust_dev_preview/examples/s3/src/s3-service-lib.rs index 15a73906a99..a67d6f4b612 100644 --- a/rust_dev_preview/examples/s3/src/s3-service-lib.rs +++ b/rust_dev_preview/examples/s3/src/s3-service-lib.rs @@ -61,7 +61,7 @@ pub async fn delete_objects(client: &Client, bucket_name: &str) -> Result Ok(return_keys), _ => Err(Error::unhandled( "There were still objects left in the bucket.", diff --git a/rust_dev_preview/examples/testing/src/enums.rs b/rust_dev_preview/examples/testing/src/enums.rs index 75279478c32..08ab3dad4c0 100644 --- a/rust_dev_preview/examples/testing/src/enums.rs +++ b/rust_dev_preview/examples/testing/src/enums.rs @@ -72,7 +72,7 @@ impl ListObjects { Ok(ListObjectsResult { objects: response.contents().to_vec(), next_continuation_token: response.next_continuation_token.clone(), - has_more: response.is_truncated(), + has_more: response.is_truncated() == Some(true), }) } // snippet-end:[testing.rust.enums-real-list-objects] @@ -122,7 +122,7 @@ async fn determine_prefix_file_size( // Add up the file sizes we got back for object in result.objects { - total_size_bytes += object.size() as usize; + total_size_bytes += object.size().unwrap_or(0) as usize; } // Handle pagination, and break the loop if there are no more pages diff --git a/rust_dev_preview/examples/testing/src/main.rs b/rust_dev_preview/examples/testing/src/main.rs index cc3973d8cec..cdd09b0363c 100644 --- a/rust_dev_preview/examples/testing/src/main.rs +++ b/rust_dev_preview/examples/testing/src/main.rs @@ -56,12 +56,12 @@ async fn determine_prefix_file_size( // Add up the file sizes we got back let contents = response.contents(); for object in contents { - total_size_bytes += object.size() as usize; + total_size_bytes += object.size().unwrap_or(0) as usize; } // Handle pagination, and break the loop if there are no more pages next_token = response.next_continuation_token.clone(); - if !response.is_truncated() { + if response.is_truncated() != Some(true) { break; } } diff --git a/rust_dev_preview/examples/testing/src/replay.rs b/rust_dev_preview/examples/testing/src/replay.rs index f6f349cbca6..2253023d632 100644 --- a/rust_dev_preview/examples/testing/src/replay.rs +++ b/rust_dev_preview/examples/testing/src/replay.rs @@ -29,7 +29,7 @@ pub async fn determine_prefix_file_size( // Add up the file sizes we got back for object in result.contents() { - total_size_bytes += object.size() as usize; + total_size_bytes += object.size().unwrap_or(0) as usize; } // Handle pagination, and break the loop if there are no more pages diff --git a/rust_dev_preview/examples/testing/src/traits.rs b/rust_dev_preview/examples/testing/src/traits.rs index 5358423bc23..2d241821346 100644 --- a/rust_dev_preview/examples/testing/src/traits.rs +++ b/rust_dev_preview/examples/testing/src/traits.rs @@ -57,7 +57,7 @@ impl ListObjects for S3ListObjects { Ok(ListObjectsResult { objects: response.contents().to_vec(), next_continuation_token: response.next_continuation_token.clone(), - has_more: response.is_truncated(), + has_more: response.is_truncated() == Some(true), }) } } @@ -119,7 +119,7 @@ pub async fn determine_prefix_file_size( // Add up the file sizes we got back for object in result.objects { - total_size_bytes += object.size() as usize; + total_size_bytes += object.size().unwrap_or(0) as usize; } // Handle pagination, and break the loop if there are no more pages diff --git a/rust_dev_preview/examples/testing/src/wrapper.rs b/rust_dev_preview/examples/testing/src/wrapper.rs index 6dae10e9f6f..bcc0189bc72 100644 --- a/rust_dev_preview/examples/testing/src/wrapper.rs +++ b/rust_dev_preview/examples/testing/src/wrapper.rs @@ -68,7 +68,7 @@ pub async fn determine_prefix_file_size( // Add up the file sizes we got back for object in result.contents() { - total_size_bytes += object.size() as usize; + total_size_bytes += object.size().unwrap_or(0) as usize; } // Handle pagination, and break the loop if there are no more pages