INNER CODE UNIT · Rust
total_size
nogibjj/rust-mlops-template · async-lambda-s3/src/lib.rs:40
let total_size: i64 = sizes.iter().sum();
println!("Total size of bucket {} is {} bytes", bucket, total_size);
Ok(total_size)
}
/* Use list_buckets to get a list of all buckets in an AWS S3 account
return a vector of all bucket sizes.
If there is an error continue to the next bucket only print if verbose is true
Return the vector
*/
pub async fn list_bucket_sizes(client: &Client, verbose: Option<bool>) -> Result<Vec<i64>, Error> {
let verbose = verbose.unwrap_or(false);
let buckets = list_buckets(client).await.unwrap();
let mut bucket_sizes: Vec<i64> = Vec::new();
for bucket in buckets {
match bucket_size(client, &bucket).await {
Ok(size) => bucket_sizes.push(size),
Err(e) => {