From ff0628fe5e036425752fa4b79868163676e640c0 Mon Sep 17 00:00:00 2001 From: David Souther Date: Wed, 27 Sep 2023 14:30:07 -0400 Subject: [PATCH] Handle updates to Rust nullability from awslabs/smithy-rs#2916 --- rust_dev_preview/cross_service/Cargo.toml | 1 + .../cross_service/rest_ses/src/report.rs | 7 +- rust_dev_preview/examples/Cargo.toml | 3 + .../src/bin/list-autoscaling-groups.rs | 12 +-- .../batch/src/bin/batch-helloworld.rs | 4 +- .../cloudformation/src/bin/describe-stack.rs | 2 +- .../cloudformation/src/bin/list-stacks.rs | 4 +- .../cloudwatch/src/bin/list-metrics.rs | 4 +- .../src/bin/describe-identity-pool.rs | 4 +- .../examples/dynamodb/src/bin/crud.rs | 9 ++- .../dynamodb/src/bin/dynamodb-helloworld.rs | 39 +++++----- .../examples/dynamodb/src/bin/partiql.rs | 9 ++- .../examples/dynamodb/src/scenario/create.rs | 9 ++- .../examples/dynamodb/src/scenario/error.rs | 4 + .../dynamodb/src/scenario/movies/mod.rs | 6 +- .../dynamodb/src/scenario/movies/startup.rs | 27 ++++--- .../firehose/src/bin/put-records-batch.rs | 13 +++- rust_dev_preview/examples/glue/src/cleanup.rs | 9 +-- rust_dev_preview/examples/glue/src/lib.rs | 4 + rust_dev_preview/examples/glue/src/prepare.rs | 7 +- rust_dev_preview/examples/glue/src/run.rs | 3 +- .../examples/iam/src/bin/create-role.rs | 5 +- .../iam/src/bin/iam-getting-started.rs | 66 ++++++---------- .../examples/iam/src/iam-service-lib.rs | 16 ++-- .../kinesis/src/bin/describe-stream.rs | 11 +-- .../examples/kinesis/src/bin/list-streams.rs | 2 +- .../examples/kms/src/bin/create-key.rs | 6 +- .../examples/lambda/src/actions.rs | 2 +- .../examples/qldb/src/bin/qldb-helloworld.rs | 7 +- .../route53/src/bin/route53-helloworld.rs | 8 +- rust_dev_preview/examples/rust-toolchain.toml | 2 +- .../examples/s3/src/bin/delete-objects.rs | 10 ++- rust_dev_preview/examples/s3/src/error.rs | 8 ++ .../examples/s3/src/s3-service-lib.rs | 15 ++-- .../sagemaker/src/bin/list-training-jobs.rs | 8 +- .../sagemaker/src/bin/sagemaker-helloworld.rs | 2 +- .../examples/ses/src/bin/send-email.rs | 12 ++- .../sitewise/src/bin/describe-asset.rs | 77 ++++++------------- .../sitewise/src/bin/list-asset-models.rs | 19 ++--- .../examples/sitewise/src/bin/list-assets.rs | 28 +++---- .../examples/sitewise/src/bin/list-portals.rs | 12 +-- rust_dev_preview/examples/textract/Cargo.toml | 2 + .../textract/src/bin/analyze-document.rs | 19 +++-- rust_dev_preview/lambda/calculator/Cargo.toml | 2 +- 44 files changed, 260 insertions(+), 259 deletions(-) diff --git a/rust_dev_preview/cross_service/Cargo.toml b/rust_dev_preview/cross_service/Cargo.toml index bc1591ecd33..53430fc8687 100644 --- a/rust_dev_preview/cross_service/Cargo.toml +++ b/rust_dev_preview/cross_service/Cargo.toml @@ -1,6 +1,7 @@ # Note: this workspace exists solely for the convenience of # compiling/auto-formatting/testing all the AWS Rust SDK examples together. [workspace] +resolver = "2" members = [ "detect_faces", "detect_labels", diff --git a/rust_dev_preview/cross_service/rest_ses/src/report.rs b/rust_dev_preview/cross_service/rest_ses/src/report.rs index 1b2f590debe..ad42f3bce49 100644 --- a/rust_dev_preview/cross_service/rest_ses/src/report.rs +++ b/rust_dev_preview/cross_service/rest_ses/src/report.rs @@ -92,7 +92,12 @@ pub async fn send_report( let email = ses .send_raw_email() - .raw_message(RawMessage::builder().data(data).build()) + .raw_message( + RawMessage::builder() + .data(data) + .build() + .expect("building RawMessage"), + ) .send() .await .map_err(|err| ReportError::SesError(err.into()))?; diff --git a/rust_dev_preview/examples/Cargo.toml b/rust_dev_preview/examples/Cargo.toml index fbd021ff802..e4ca171cb72 100644 --- a/rust_dev_preview/examples/Cargo.toml +++ b/rust_dev_preview/examples/Cargo.toml @@ -1,6 +1,9 @@ # Note: this workspace exists solely for the convenience of # compiling/auto-formatting/testing all the AWS Rust SDK examples together. [workspace] + +resolver = "2" + members = [ "apigateway", "apigatewaymanagement", diff --git a/rust_dev_preview/examples/autoscaling/src/bin/list-autoscaling-groups.rs b/rust_dev_preview/examples/autoscaling/src/bin/list-autoscaling-groups.rs index 539186754c3..8bbd673c59c 100644 --- a/rust_dev_preview/examples/autoscaling/src/bin/list-autoscaling-groups.rs +++ b/rust_dev_preview/examples/autoscaling/src/bin/list-autoscaling-groups.rs @@ -27,21 +27,15 @@ async fn list_groups(client: &Client) -> Result<(), Error> { println!("Groups:"); - let groups = resp.auto_scaling_groups().unwrap_or_default(); + let groups = resp.auto_scaling_groups(); for group in groups { - println!( - "Name: {}", - group.auto_scaling_group_name().unwrap_or("Unknown"), - ); + println!("Name: {}", group.auto_scaling_group_name(),); println!( "Arn: {}", group.auto_scaling_group_arn().unwrap_or("unknown"), ); - println!( - "Zones: {:?}", - group.availability_zones().unwrap_or_default(), - ); + println!("Zones: {:?}", group.availability_zones(),); println!(); } diff --git a/rust_dev_preview/examples/batch/src/bin/batch-helloworld.rs b/rust_dev_preview/examples/batch/src/bin/batch-helloworld.rs index 01fd24c2f0e..62b2714e051 100644 --- a/rust_dev_preview/examples/batch/src/bin/batch-helloworld.rs +++ b/rust_dev_preview/examples/batch/src/bin/batch-helloworld.rs @@ -28,8 +28,8 @@ async fn show_envs(client: &Client) -> Result<(), Error> { let compute_envs = rsp.compute_environments().unwrap_or_default(); println!("Found {} compute environments:", compute_envs.len()); for env in compute_envs { - let arn = env.compute_environment_arn().unwrap_or_default(); - let name = env.compute_environment_name().unwrap_or_default(); + let arn = env.compute_environment_arn(); + let name = env.compute_environment_name(); println!(" Name : {}", name); println!(" ARN: {}", arn); diff --git a/rust_dev_preview/examples/cloudformation/src/bin/describe-stack.rs b/rust_dev_preview/examples/cloudformation/src/bin/describe-stack.rs index 2c05e3e4b2d..2d0943f77aa 100644 --- a/rust_dev_preview/examples/cloudformation/src/bin/describe-stack.rs +++ b/rust_dev_preview/examples/cloudformation/src/bin/describe-stack.rs @@ -39,7 +39,7 @@ async fn describe_stack(client: &Client, name: &str) -> Result<(), Error> { .unwrap() .stack_status(); - println!("Stack status: {}", status.unwrap().as_ref()); + println!("Stack status: {}", status.as_str()); println!(); diff --git a/rust_dev_preview/examples/cloudformation/src/bin/list-stacks.rs b/rust_dev_preview/examples/cloudformation/src/bin/list-stacks.rs index 9314e6c5476..289807946c0 100644 --- a/rust_dev_preview/examples/cloudformation/src/bin/list-stacks.rs +++ b/rust_dev_preview/examples/cloudformation/src/bin/list-stacks.rs @@ -26,8 +26,8 @@ async fn list_stacks(client: &Client) -> Result<(), Error> { let stacks = client.list_stacks().send().await?; for stack in stacks.stack_summaries().unwrap_or_default() { - println!("{}", stack.stack_name().unwrap_or_default()); - println!(" Status: {:?}", stack.stack_status().unwrap()); + println!("{}", stack.stack_name()); + println!(" Status: {:?}", stack.stack_status()); println!(); } diff --git a/rust_dev_preview/examples/cloudwatch/src/bin/list-metrics.rs b/rust_dev_preview/examples/cloudwatch/src/bin/list-metrics.rs index d8e99c5d91d..9e91e231806 100644 --- a/rust_dev_preview/examples/cloudwatch/src/bin/list-metrics.rs +++ b/rust_dev_preview/examples/cloudwatch/src/bin/list-metrics.rs @@ -37,8 +37,8 @@ async fn show_metrics( if let Some(dimension) = metric.dimensions.as_ref() { for d in dimension { - println!(" Name: {}", d.name().unwrap_or_default()); - println!(" Value: {}", d.value().unwrap_or_default()); + println!(" Name: {}", d.name()); + println!(" Value: {}", d.value()); println!(); } } diff --git a/rust_dev_preview/examples/cognitoidentity/src/bin/describe-identity-pool.rs b/rust_dev_preview/examples/cognitoidentity/src/bin/describe-identity-pool.rs index 265035ea2a3..0a85e1d7e9a 100644 --- a/rust_dev_preview/examples/cognitoidentity/src/bin/describe-identity-pool.rs +++ b/rust_dev_preview/examples/cognitoidentity/src/bin/describe-identity-pool.rs @@ -52,8 +52,8 @@ async fn describe_pool(client: &Client, id: &str) -> Result<(), Error> { } let developer_provider = response.developer_provider_name().unwrap_or_default(); - let id = response.identity_pool_id().unwrap_or_default(); - let name = response.identity_pool_name().unwrap_or_default(); + let id = response.identity_pool_id(); + let name = response.identity_pool_name(); println!(" Developer provider: {}", developer_provider); println!(" Identity pool ID: {}", id); diff --git a/rust_dev_preview/examples/dynamodb/src/bin/crud.rs b/rust_dev_preview/examples/dynamodb/src/bin/crud.rs index bc33da8f74a..97fb15fa005 100644 --- a/rust_dev_preview/examples/dynamodb/src/bin/crud.rs +++ b/rust_dev_preview/examples/dynamodb/src/bin/crud.rs @@ -56,17 +56,20 @@ async fn make_table( let ad = AttributeDefinition::builder() .attribute_name(key) .attribute_type(ScalarAttributeType::S) - .build(); + .build() + .expect("creating AttributeDefinition"); let ks = KeySchemaElement::builder() .attribute_name(key) .key_type(KeyType::Hash) - .build(); + .build() + .expect("creating KeySchemaElement"); let pt = ProvisionedThroughput::builder() .read_capacity_units(10) .write_capacity_units(5) - .build(); + .build() + .expect("creating ProvisionedThroughput"); match client .create_table() diff --git a/rust_dev_preview/examples/dynamodb/src/bin/dynamodb-helloworld.rs b/rust_dev_preview/examples/dynamodb/src/bin/dynamodb-helloworld.rs index 47320231f77..29b1892bb6f 100644 --- a/rust_dev_preview/examples/dynamodb/src/bin/dynamodb-helloworld.rs +++ b/rust_dev_preview/examples/dynamodb/src/bin/dynamodb-helloworld.rs @@ -37,27 +37,30 @@ async fn list_tables(client: &Client) -> Result<(), Error> { // Creates the test-table table. // snippet-start:[dynamodb.rust.dynamodb-helloworld-create_table] async fn create_table(client: &Client) -> Result<(), Error> { + let ks = KeySchemaElement::builder() + .attribute_name("k") + .key_type(KeyType::Hash) + .build() + .expect("creating KeySchemaElement"); + + let ad = AttributeDefinition::builder() + .attribute_name("k") + .attribute_type(ScalarAttributeType::S) + .build() + .expect("creating AttributeDefinition"); + + let pt = ProvisionedThroughput::builder() + .write_capacity_units(10) + .read_capacity_units(10) + .build() + .expect("creating ProvisionedThroughput"); + let new_table = client .create_table() .table_name("test-table") - .key_schema( - KeySchemaElement::builder() - .attribute_name("k") - .key_type(KeyType::Hash) - .build(), - ) - .attribute_definitions( - AttributeDefinition::builder() - .attribute_name("k") - .attribute_type(ScalarAttributeType::S) - .build(), - ) - .provisioned_throughput( - ProvisionedThroughput::builder() - .write_capacity_units(10) - .read_capacity_units(10) - .build(), - ) + .key_schema(ks) + .attribute_definitions(ad) + .provisioned_throughput(pt) .send() .await?; println!( diff --git a/rust_dev_preview/examples/dynamodb/src/bin/partiql.rs b/rust_dev_preview/examples/dynamodb/src/bin/partiql.rs index 09ddf90e95b..9e975efa541 100644 --- a/rust_dev_preview/examples/dynamodb/src/bin/partiql.rs +++ b/rust_dev_preview/examples/dynamodb/src/bin/partiql.rs @@ -56,17 +56,20 @@ async fn make_table( let ad = AttributeDefinition::builder() .attribute_name(key) .attribute_type(ScalarAttributeType::S) - .build(); + .build() + .expect("creating AttributeDefinition"); let ks = KeySchemaElement::builder() .attribute_name(key) .key_type(KeyType::Hash) - .build(); + .build() + .expect("creating KeySchemaElement"); let pt = ProvisionedThroughput::builder() .read_capacity_units(10) .write_capacity_units(5) - .build(); + .build() + .expect("creating ProvisionedThroughput"); match client .create_table() diff --git a/rust_dev_preview/examples/dynamodb/src/scenario/create.rs b/rust_dev_preview/examples/dynamodb/src/scenario/create.rs index b7440ee1611..e0207b4dba2 100644 --- a/rust_dev_preview/examples/dynamodb/src/scenario/create.rs +++ b/rust_dev_preview/examples/dynamodb/src/scenario/create.rs @@ -23,17 +23,20 @@ pub async fn create_table( let ad = AttributeDefinition::builder() .attribute_name(&a_name) .attribute_type(ScalarAttributeType::S) - .build(); + .build() + .map_err(Error::BuildError)?; let ks = KeySchemaElement::builder() .attribute_name(&a_name) .key_type(KeyType::Hash) - .build(); + .build() + .map_err(Error::BuildError)?; let pt = ProvisionedThroughput::builder() .read_capacity_units(10) .write_capacity_units(5) - .build(); + .build() + .map_err(Error::BuildError)?; let create_table_response = client .create_table() diff --git a/rust_dev_preview/examples/dynamodb/src/scenario/error.rs b/rust_dev_preview/examples/dynamodb/src/scenario/error.rs index f265f09d92b..71b1860d1d4 100644 --- a/rust_dev_preview/examples/dynamodb/src/scenario/error.rs +++ b/rust_dev_preview/examples/dynamodb/src/scenario/error.rs @@ -5,10 +5,14 @@ use std::error::Error as StdError; +use aws_smithy_http::operation::error::BuildError; + #[derive(thiserror::Error, Debug)] pub enum Error { #[error("table was not ready after several attempts: {0}")] TableNotReady(String), + #[error("problem building schema key or element: {0}")] + BuildError(BuildError), #[error("unhandled error")] Unhandled(#[source] Box), } diff --git a/rust_dev_preview/examples/dynamodb/src/scenario/movies/mod.rs b/rust_dev_preview/examples/dynamodb/src/scenario/movies/mod.rs index 9d65dd9f79f..64645253f82 100644 --- a/rust_dev_preview/examples/dynamodb/src/scenario/movies/mod.rs +++ b/rust_dev_preview/examples/dynamodb/src/scenario/movies/mod.rs @@ -1,5 +1,6 @@ use aws_sdk_dynamodb::error::SdkError; use aws_sdk_dynamodb::types::{AttributeValue, PutRequest}; +use aws_smithy_http::operation::error::BuildError; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; @@ -140,8 +141,9 @@ impl From<&HashMap> for Movie { } } -impl From<&Movie> for PutRequest { - fn from(movie: &Movie) -> Self { +impl TryFrom<&Movie> for PutRequest { + type Error = BuildError; + fn try_from(movie: &Movie) -> Result { PutRequest::builder() .item("year", AttributeValue::N(movie.year.to_string())) .item("title", AttributeValue::S(movie.title.clone())) diff --git a/rust_dev_preview/examples/dynamodb/src/scenario/movies/startup.rs b/rust_dev_preview/examples/dynamodb/src/scenario/movies/startup.rs index 5ff48ba988d..d24be1d3573 100644 --- a/rust_dev_preview/examples/dynamodb/src/scenario/movies/startup.rs +++ b/rust_dev_preview/examples/dynamodb/src/scenario/movies/startup.rs @@ -22,7 +22,7 @@ pub async fn initialize(client: &Client, table_name: &str) -> Result<(), Error> info!("Found existing table {table_name}"); } else { info!("Table does not exist, creating {table_name}"); - create_table(client, table_name, "year", "title", CAPACITY) + create_table(client, table_name, "year", "title", CAPACITY)? .send() .await?; await_table(client, table_name).await?; @@ -54,41 +54,46 @@ pub fn create_table( primary_key: &str, sort_key: &str, capacity: i64, -) -> CreateTableFluentBuilder { +) -> Result { info!("Creating table: {table_name} with capacity {capacity} and key structure {primary_key}:{sort_key}"); - client + Ok(client .create_table() .table_name(table_name) .key_schema( KeySchemaElement::builder() .attribute_name(primary_key) .key_type(KeyType::Hash) - .build(), + .build() + .expect("Failed to build KeySchema"), ) .attribute_definitions( AttributeDefinition::builder() .attribute_name(primary_key) .attribute_type(ScalarAttributeType::N) - .build(), + .build() + .expect("Failed to build attribute definition"), ) .key_schema( KeySchemaElement::builder() .attribute_name(sort_key) .key_type(KeyType::Range) - .build(), + .build() + .expect("Failed to build KeySchema"), ) .attribute_definitions( AttributeDefinition::builder() .attribute_name(sort_key) .attribute_type(ScalarAttributeType::S) - .build(), + .build() + .expect("Failed to build attribute definition"), ) .provisioned_throughput( ProvisionedThroughput::builder() .read_capacity_units(capacity) .write_capacity_units(capacity) - .build(), - ) + .build() + .expect("Failed to specify ProvisionedThroughput"), + )) } // snippet-end:[dynamodb.rust.movies-create_table_request] @@ -133,7 +138,9 @@ pub async fn load_data(client: &Client, table_name: &str) -> Result<(), Error> { .iter() .map(|v| { WriteRequest::builder() - .set_put_request(Some(v.into())) + .set_put_request(Some( + v.try_into().expect("Failed to convert movie to PutRequest"), + )) .build() }) .collect::>(); diff --git a/rust_dev_preview/examples/firehose/src/bin/put-records-batch.rs b/rust_dev_preview/examples/firehose/src/bin/put-records-batch.rs index 13d46099bfd..e082411d3b9 100644 --- a/rust_dev_preview/examples/firehose/src/bin/put-records-batch.rs +++ b/rust_dev_preview/examples/firehose/src/bin/put-records-batch.rs @@ -33,12 +33,12 @@ struct Opt { async fn put_record_batch( client: &Client, stream: &str, - data: Option>, + data: Vec, ) -> Result> { client .put_record_batch() .delivery_stream_name(stream) - .set_records(data) + .set_records(Some(data)) .send() .await } @@ -83,9 +83,14 @@ async fn main() -> Result<(), Error> { let mut data = Vec::with_capacity(500); let payload = String::from("Some random payload"); let tmp = Some(Blob::new(payload.to_string())); - data.push(Record::builder().set_data(tmp).build()); + data.push( + Record::builder() + .set_data(tmp) + .build() + .expect("Failed to create a new record"), + ); - let resp = put_record_batch(&client, &firehose_stream, Some(data)).await; + let resp = put_record_batch(&client, &firehose_stream, data).await; match resp { Ok(_) => Ok(()), Err(e) => Err(Error::from(e)), diff --git a/rust_dev_preview/examples/glue/src/cleanup.rs b/rust_dev_preview/examples/glue/src/cleanup.rs index 04fda937a66..9ab9d21c6a1 100644 --- a/rust_dev_preview/examples/glue/src/cleanup.rs +++ b/rust_dev_preview/examples/glue/src/cleanup.rs @@ -23,10 +23,7 @@ impl GlueScenario { // snippet-start:[rust.glue.delete_table] for t in &self.tables { glue.delete_table() - .name( - t.name() - .ok_or_else(|| GlueMvpError::Unknown("Couldn't find table".to_string()))?, - ) + .name(t.name()) .database_name(self.database()) .send() .await @@ -106,9 +103,7 @@ impl GlueScenario { .to_owned(); if let Some(database) = database.database() { - return Err(GlueMvpError::Cleanup( - database.name().unwrap_or_default().into(), - )); + return Err(GlueMvpError::Cleanup(database.name().into())); } let crawler = glue diff --git a/rust_dev_preview/examples/glue/src/lib.rs b/rust_dev_preview/examples/glue/src/lib.rs index d8d4f6462c6..1b2599e39d6 100644 --- a/rust_dev_preview/examples/glue/src/lib.rs +++ b/rust_dev_preview/examples/glue/src/lib.rs @@ -7,6 +7,7 @@ pub mod prepare; pub mod run; use aws_sdk_glue::types::Table; +use aws_smithy_http::operation::error::BuildError; use clap::Parser; use secrecy::Secret; use std::time::Duration; @@ -162,6 +163,9 @@ pub enum GlueMvpError { #[error("Failed to clean up: {0}")] Cleanup(String), + #[error("Failed to build intermediate: {0}")] + BuildError(BuildError), + #[error("Unknown Glue MVP Error: {0}")] Unknown(String), } diff --git a/rust_dev_preview/examples/glue/src/prepare.rs b/rust_dev_preview/examples/glue/src/prepare.rs index 155541a87d0..e484dddf685 100644 --- a/rust_dev_preview/examples/glue/src/prepare.rs +++ b/rust_dev_preview/examples/glue/src/prepare.rs @@ -27,7 +27,12 @@ impl GlueScenario { let create_database = glue .create_database() - .database_input(DatabaseInput::builder().name(self.database()).build()) + .database_input( + DatabaseInput::builder() + .name(self.database()) + .build() + .map_err(GlueMvpError::BuildError)?, + ) .send() .await; diff --git a/rust_dev_preview/examples/glue/src/run.rs b/rust_dev_preview/examples/glue/src/run.rs index a25e172162f..c70648bbd67 100644 --- a/rust_dev_preview/examples/glue/src/run.rs +++ b/rust_dev_preview/examples/glue/src/run.rs @@ -48,8 +48,7 @@ impl GlueScenario { self.tables .get(0) .ok_or_else(|| GlueMvpError::Unknown("Missing crawler table".into()))? - .name() - .ok_or_else(|| GlueMvpError::Unknown("Crawler table without a name".into()))?, + .name(), ) .arguments("--output_bucket_url", self.bucket()) .send() diff --git a/rust_dev_preview/examples/iam/src/bin/create-role.rs b/rust_dev_preview/examples/iam/src/bin/create-role.rs index 3427015f333..8d408c9baf7 100644 --- a/rust_dev_preview/examples/iam/src/bin/create-role.rs +++ b/rust_dev_preview/examples/iam/src/bin/create-role.rs @@ -41,10 +41,7 @@ async fn make_role(client: &Client, policy: &str, name: &str) -> String { match resp { Ok(output) => { - format!( - "Created role with ARN {}", - output.role().unwrap().arn().unwrap() - ) + format!("Created role with ARN {}", output.role().unwrap().arn()) } Err(err) => format!("Error creating role: {:?}", err), } diff --git a/rust_dev_preview/examples/iam/src/bin/iam-getting-started.rs b/rust_dev_preview/examples/iam/src/bin/iam-getting-started.rs index 418407992a9..be95975aed3 100644 --- a/rust_dev_preview/examples/iam/src/bin/iam-getting-started.rs +++ b/rust_dev_preview/examples/iam/src/bin/iam-getting-started.rs @@ -28,7 +28,6 @@ use aws_sdk_iam::Error as iamError; use aws_sdk_iam::{config::Credentials as iamCredentials, config::Region, Client as iamClient}; use aws_sdk_s3::Client as s3Client; use aws_sdk_sts::Client as stsClient; -use std::borrow::Borrow; use tokio::time::{sleep, Duration}; use uuid::Uuid; @@ -99,12 +98,9 @@ async fn run_iam_operations( ) -> Result<(), iamError> { // snippet-start:[rust.example_code.iam.iam_basics.create_user] let user = iam_service::create_user(&client, &format!("{}{}", "iam_demo_user_", uuid)).await?; - println!( - "Created the user with the name: {}", - user.user_name.as_ref().unwrap() - ); + println!("Created the user with the name: {}", user.user_name()); // snippet-end:[rust.example_code.iam.iam_basics.create_user] - let key = iam_service::create_access_key(&client, user.user_name.as_ref().unwrap()).await?; + let key = iam_service::create_access_key(&client, user.user_name()).await?; // snippet-start:[rust.example_code.iam.iam_basics.setup_role_policy_document] let assume_role_policy_document = "{ @@ -116,7 +112,7 @@ async fn run_iam_operations( }] }" .to_string() - .replace("{}", user.arn.as_ref().unwrap()); + .replace("{}", user.arn()); // snippet-end:[rust.example_code.iam.iam_basics.setup_role_policy_document] // snippet-start:[rust.example_code.iam.iam_basics.create_role] @@ -126,10 +122,7 @@ async fn run_iam_operations( &assume_role_policy_document, ) .await?; - println!( - "Created the role with the ARN: {}", - assume_role_role.arn.as_ref().unwrap() - ); + println!("Created the role with the ARN: {}", assume_role_role.arn()); // snippet-end:[rust.example_code.iam.iam_basics.create_role] // snippet-start:[rust.example_code.iam.iam_basics.create_policy] @@ -156,18 +149,13 @@ async fn run_iam_operations( // snippet-end:[rust.example_code.iam.iam_basics.attach_role_policy] let inline_policy_name = format!("{}{}", "iam_demo_inline_policy_", uuid); - let inline_policy_document = - inline_policy_document.replace("{}", assume_role_role.arn.as_ref().unwrap()); + let inline_policy_document = inline_policy_document.replace("{}", assume_role_role.arn()); iam_service::create_user_policy(&client, &user, &inline_policy_name, &inline_policy_document) .await?; println!("Created inline policy."); //First, fail to list the buckets with the user. - let creds = iamCredentials::from_keys( - key.access_key_id.as_ref().unwrap(), - key.secret_access_key.as_ref().unwrap(), - None, - ); + let creds = iamCredentials::from_keys(key.access_key_id(), key.secret_access_key(), None); let fail_config = aws_config::from_env() .credentials_provider(creds.clone()) .load() @@ -191,7 +179,7 @@ async fn run_iam_operations( sleep(Duration::from_secs(10)).await; let assumed_role = sts_client .assume_role() - .role_arn(assume_role_role.arn.as_ref().unwrap()) + .role_arn(assume_role_role.arn()) .role_session_name(&format!("{}{}", "iam_demo_assumerole_session_", uuid)) .send() .await; @@ -205,27 +193,24 @@ async fn run_iam_operations( .credentials .as_ref() .unwrap() - .access_key_id - .as_ref() - .unwrap(), + .access_key_id(), assumed_role .as_ref() .unwrap() .credentials .as_ref() .unwrap() - .secret_access_key - .as_ref() - .unwrap(), - assumed_role - .as_ref() - .unwrap() - .credentials - .as_ref() - .unwrap() - .session_token - .borrow() - .clone(), + .secret_access_key(), + Some( + assumed_role + .as_ref() + .unwrap() + .credentials + .as_ref() + .unwrap() + .session_token + .clone(), + ), ); let succeed_config = aws_config::from_env() @@ -248,22 +233,19 @@ async fn run_iam_operations( //Clean up. iam_service::detach_role_policy( &client, - assume_role_role.role_name.as_ref().unwrap(), - list_all_buckets_policy.arn.as_ref().unwrap(), + assume_role_role.role_name(), + list_all_buckets_policy.arn().unwrap_or_default(), ) .await?; iam_service::delete_policy(&client, list_all_buckets_policy).await?; iam_service::delete_role(&client, &assume_role_role).await?; - println!( - "Deleted role {}", - assume_role_role.role_name.as_ref().unwrap() - ); + println!("Deleted role {}", assume_role_role.role_name()); iam_service::delete_access_key(&client, &user, &key).await?; - println!("Deleted key for {}", key.user_name.as_ref().unwrap()); + println!("Deleted key for {}", key.user_name()); iam_service::delete_user_policy(&client, &user, &inline_policy_name).await?; println!("Deleted inline user policy: {}", inline_policy_name); iam_service::delete_user(&client, &user).await?; - println!("Deleted user {}", user.user_name.as_ref().unwrap()); + println!("Deleted user {}", user.user_name()); Ok(()) } diff --git a/rust_dev_preview/examples/iam/src/iam-service-lib.rs b/rust_dev_preview/examples/iam/src/iam-service-lib.rs index 877e099540c..eed41ea0d66 100644 --- a/rust_dev_preview/examples/iam/src/iam-service-lib.rs +++ b/rust_dev_preview/examples/iam/src/iam-service-lib.rs @@ -150,7 +150,7 @@ pub async fn create_user_policy( ) -> Result<(), iamError> { client .put_user_policy() - .user_name(user.user_name.as_ref().unwrap()) + .user_name(user.user_name()) .policy_name(policy_name) .policy_document(policy_document) .send() @@ -165,7 +165,7 @@ pub async fn delete_role(client: &iamClient, role: &Role) -> Result<(), iamError let role = role.clone(); while client .delete_role() - .role_name(role.role_name.as_ref().unwrap()) + .role_name(role.role_name()) .send() .await .is_err() @@ -200,7 +200,7 @@ pub async fn delete_user(client: &iamClient, user: &User) -> Result<(), SdkError let response: Result<(), SdkError> = loop { match client .delete_user() - .user_name(user.user_name.as_ref().unwrap()) + .user_name(user.user_name()) .send() .await { @@ -229,8 +229,8 @@ pub async fn attach_role_policy( ) -> Result> { client .attach_role_policy() - .role_name(role.role_name.as_ref().unwrap()) - .policy_arn(policy.arn.as_ref().unwrap()) + .role_name(role.role_name()) + .policy_arn(policy.arn().unwrap_or_default()) .send() .await } @@ -303,8 +303,8 @@ pub async fn delete_access_key( loop { match client .delete_access_key() - .user_name(user.user_name.as_ref().unwrap()) - .access_key_id(key.access_key_id.as_ref().unwrap()) + .user_name(user.user_name()) + .access_key_id(key.access_key_id()) .send() .await { @@ -357,7 +357,7 @@ pub async fn delete_user_policy( ) -> Result<(), SdkError> { client .delete_user_policy() - .user_name(user.user_name.as_ref().unwrap()) + .user_name(user.user_name()) .policy_name(policy_name) .send() .await?; diff --git a/rust_dev_preview/examples/kinesis/src/bin/describe-stream.rs b/rust_dev_preview/examples/kinesis/src/bin/describe-stream.rs index 696a7726b16..03325cd00dd 100644 --- a/rust_dev_preview/examples/kinesis/src/bin/describe-stream.rs +++ b/rust_dev_preview/examples/kinesis/src/bin/describe-stream.rs @@ -32,13 +32,10 @@ async fn show_stream(client: &Client, stream: &str) -> Result<(), Error> { let desc = resp.stream_description.unwrap(); println!("Stream description:"); - println!(" Name: {}:", desc.stream_name.unwrap()); - println!(" Status: {:?}", desc.stream_status.unwrap()); - println!(" Open shards: {:?}", desc.shards.unwrap().len()); - println!( - " Retention (hours): {}", - desc.retention_period_hours.unwrap() - ); + println!(" Name: {}:", desc.stream_name()); + println!(" Status: {:?}", desc.stream_status()); + println!(" Open shards: {:?}", desc.shards.len()); + println!(" Retention (hours): {}", desc.retention_period_hours()); println!(" Encryption: {:?}", desc.encryption_type.unwrap()); Ok(()) diff --git a/rust_dev_preview/examples/kinesis/src/bin/list-streams.rs b/rust_dev_preview/examples/kinesis/src/bin/list-streams.rs index a65ad4ecf52..e4b4a946c42 100644 --- a/rust_dev_preview/examples/kinesis/src/bin/list-streams.rs +++ b/rust_dev_preview/examples/kinesis/src/bin/list-streams.rs @@ -27,7 +27,7 @@ async fn show_streams(client: &Client) -> Result<(), Error> { println!("Stream names:"); - let streams = resp.stream_names.unwrap_or_default(); + let streams = resp.stream_names; for stream in &streams { println!(" {}", stream); } diff --git a/rust_dev_preview/examples/kms/src/bin/create-key.rs b/rust_dev_preview/examples/kms/src/bin/create-key.rs index aeedb65b38b..5f5e2e281dc 100644 --- a/rust_dev_preview/examples/kms/src/bin/create-key.rs +++ b/rust_dev_preview/examples/kms/src/bin/create-key.rs @@ -25,11 +25,7 @@ struct Opt { async fn make_key(client: &Client) -> Result<(), Error> { let resp = client.create_key().send().await?; - let id = resp - .key_metadata - .unwrap() - .key_id - .unwrap_or_else(|| String::from("No ID!")); + let id = resp.key_metadata.as_ref().unwrap().key_id(); println!("Key: {}", id); diff --git a/rust_dev_preview/examples/lambda/src/actions.rs b/rust_dev_preview/examples/lambda/src/actions.rs index 138958c725e..7867f565e5b 100644 --- a/rust_dev_preview/examples/lambda/src/actions.rs +++ b/rust_dev_preview/examples/lambda/src/actions.rs @@ -258,7 +258,7 @@ impl LambdaManager { .create_function() .function_name(self.lambda_name.clone()) .code(code) - .role(role.role().unwrap().arn().unwrap()) + .role(role.role().map(|r| r.arn()).unwrap_or_default()) .runtime(aws_sdk_lambda::types::Runtime::Providedal2) .handler("_unused") .send() diff --git a/rust_dev_preview/examples/qldb/src/bin/qldb-helloworld.rs b/rust_dev_preview/examples/qldb/src/bin/qldb-helloworld.rs index b3e2ab9f7b9..9141f2ed236 100644 --- a/rust_dev_preview/examples/qldb/src/bin/qldb-helloworld.rs +++ b/rust_dev_preview/examples/qldb/src/bin/qldb-helloworld.rs @@ -30,7 +30,12 @@ struct Opt { async fn start(client: &Client, ledger: &str) -> Result<(), Error> { let result = client .send_command() - .start_session(StartSessionRequest::builder().ledger_name(ledger).build()) + .start_session( + StartSessionRequest::builder() + .ledger_name(ledger) + .build() + .expect("building StartSessionRequest"), + ) .send() .await?; diff --git a/rust_dev_preview/examples/route53/src/bin/route53-helloworld.rs b/rust_dev_preview/examples/route53/src/bin/route53-helloworld.rs index 7f1c10e24f9..e25a5965d7a 100644 --- a/rust_dev_preview/examples/route53/src/bin/route53-helloworld.rs +++ b/rust_dev_preview/examples/route53/src/bin/route53-helloworld.rs @@ -27,16 +27,16 @@ async fn show_host_info(client: &aws_sdk_route53::Client) -> Result<(), aws_sdk_ println!( "Number of hosted zones in region : {}", - hosted_zone_count.hosted_zone_count().unwrap_or_default(), + hosted_zone_count.hosted_zone_count(), ); let hosted_zones = client.list_hosted_zones().send().await?; println!("Zones:"); - for hz in hosted_zones.hosted_zones().unwrap_or_default() { - let zone_name = hz.name().unwrap_or_default(); - let zone_id = hz.id().unwrap_or_default(); + for hz in hosted_zones.hosted_zones() { + let zone_name = hz.name(); + let zone_id = hz.id(); println!(" ID : {}", zone_id); println!(" Name : {}", zone_name); diff --git a/rust_dev_preview/examples/rust-toolchain.toml b/rust_dev_preview/examples/rust-toolchain.toml index 41755a2bed6..0ec68c05821 100644 --- a/rust_dev_preview/examples/rust-toolchain.toml +++ b/rust_dev_preview/examples/rust-toolchain.toml @@ -1,3 +1,3 @@ # This should be kept in sync with https://github.com/awslabs/aws-sdk-rust#supported-rust-versions-msrv [toolchain] -channel = "1.69.0" +channel = "stable" diff --git a/rust_dev_preview/examples/s3/src/bin/delete-objects.rs b/rust_dev_preview/examples/s3/src/bin/delete-objects.rs index dca9cc4249d..9cdcb3c1577 100644 --- a/rust_dev_preview/examples/s3/src/bin/delete-objects.rs +++ b/rust_dev_preview/examples/s3/src/bin/delete-objects.rs @@ -35,11 +35,17 @@ async fn remove_objects(client: &Client, bucket: &str, objects: Vec) -> let mut delete_objects: Vec = vec![]; for obj in objects { - let obj_id = ObjectIdentifier::builder().set_key(Some(obj)).build(); + let obj_id = ObjectIdentifier::builder() + .set_key(Some(obj)) + .build() + .expect("building ObjectIdentifier"); delete_objects.push(obj_id); } - let delete = Delete::builder().set_objects(Some(delete_objects)).build(); + let delete = Delete::builder() + .set_objects(Some(delete_objects)) + .build() + .expect("building Delete"); client .delete_objects() diff --git a/rust_dev_preview/examples/s3/src/error.rs b/rust_dev_preview/examples/s3/src/error.rs index d3f775a2c71..3eae3848041 100644 --- a/rust_dev_preview/examples/s3/src/error.rs +++ b/rust_dev_preview/examples/s3/src/error.rs @@ -5,6 +5,8 @@ use std::error::Error as StdError; +use aws_smithy_http::operation::error::BuildError; + #[derive(thiserror::Error, Debug)] #[error("unhandled error")] pub struct Error { @@ -26,6 +28,12 @@ impl From for Error { } } +impl From for Error { + fn from(source: BuildError) -> Self { + Self::unhandled(source) + } +} + impl From> for Error where T: StdError + Send + Sync + 'static, 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 6e34e634ebd..93238721fe1 100644 --- a/rust_dev_preview/examples/s3/src/s3-service-lib.rs +++ b/rust_dev_preview/examples/s3/src/s3-service-lib.rs @@ -38,19 +38,22 @@ pub async fn delete_objects(client: &Client, bucket_name: &str) -> Result Result<(), Error> { println!("Jobs:"); - for j in job_details.training_job_summaries().unwrap_or_default() { - let name = j.training_job_name().unwrap_or_default(); - let creation_time = j.creation_time().unwrap().to_chrono_utc()?; + for j in job_details.training_job_summaries() { + let name = j.training_job_name(); + let creation_time = j.creation_time().to_chrono_utc()?; let training_end_time = j.training_end_time().unwrap().to_chrono_utc()?; - let status = j.training_job_status().unwrap(); + let status = j.training_job_status(); let duration = training_end_time - creation_time; println!(" Name: {}", name); diff --git a/rust_dev_preview/examples/sagemaker/src/bin/sagemaker-helloworld.rs b/rust_dev_preview/examples/sagemaker/src/bin/sagemaker-helloworld.rs index 3caa5f020ed..99fe6277eb6 100644 --- a/rust_dev_preview/examples/sagemaker/src/bin/sagemaker-helloworld.rs +++ b/rust_dev_preview/examples/sagemaker/src/bin/sagemaker-helloworld.rs @@ -30,7 +30,7 @@ async fn show_instances(client: &Client) -> Result<(), Error> { for n in notebooks.notebook_instances().unwrap_or_default() { let n_instance_type = n.instance_type().unwrap(); let n_status = n.notebook_instance_status().unwrap(); - let n_name = n.notebook_instance_name().unwrap_or_default(); + let n_name = n.notebook_instance_name(); println!(" Name : {}", n_name); println!(" Status : {}", n_status.as_ref()); diff --git a/rust_dev_preview/examples/ses/src/bin/send-email.rs b/rust_dev_preview/examples/ses/src/bin/send-email.rs index d98210e939f..a21568f47fe 100644 --- a/rust_dev_preview/examples/ses/src/bin/send-email.rs +++ b/rust_dev_preview/examples/ses/src/bin/send-email.rs @@ -62,8 +62,16 @@ async fn send_message( let mut dest: Destination = Destination::builder().build(); dest.to_addresses = Some(cs); - let subject_content = Content::builder().data(subject).charset("UTF-8").build(); - let body_content = Content::builder().data(message).charset("UTF-8").build(); + let subject_content = Content::builder() + .data(subject) + .charset("UTF-8") + .build() + .expect("building Content"); + let body_content = Content::builder() + .data(message) + .charset("UTF-8") + .build() + .expect("building Content"); let body = Body::builder().text(body_content).build(); let msg = Message::builder() diff --git a/rust_dev_preview/examples/sitewise/src/bin/describe-asset.rs b/rust_dev_preview/examples/sitewise/src/bin/describe-asset.rs index d8af96c35aa..8a54388417d 100644 --- a/rust_dev_preview/examples/sitewise/src/bin/describe-asset.rs +++ b/rust_dev_preview/examples/sitewise/src/bin/describe-asset.rs @@ -39,50 +39,44 @@ async fn list_assets(client: &Client, asset_id: Option) -> Result<(), Er println!("Your Asset:"); - println!(" Asset ID: {}", asset.asset_id().unwrap_or_default()); - println!(" Asset ARN: {}", asset.asset_arn().unwrap_or_default()); - println!(" Asset Name: {}", asset.asset_name().unwrap_or_default()); - println!( - " Asset Model ID: {}", - asset.asset_model_id().unwrap_or_default() - ); + println!(" Asset ID: {}", asset.asset_id()); + println!(" Asset ARN: {}", asset.asset_arn()); + println!(" Asset Name: {}", asset.asset_name()); + println!(" Asset Model ID: {}", asset.asset_model_id()); println!( " Asset Creation Date: {}", - asset.asset_creation_date().unwrap().to_chrono_utc()? + asset.asset_creation_date().to_chrono_utc()? ); println!( " Asset Last Update Date: {}", - asset.asset_last_update_date().unwrap().to_chrono_utc()? + asset.asset_last_update_date().to_chrono_utc()? ); println!( " Asset Status: {}", - asset.asset_status().unwrap().state().unwrap().as_str() + asset.asset_status().unwrap().state().as_str() ); println!(" Assets Hierarchies:"); - for asset_hierarchy in asset.asset_hierarchies().unwrap() { - println!(" ID: {}", asset_hierarchy.id().unwrap_or_default()); - println!(" Name: {}", asset_hierarchy.name().unwrap_or_default()); + for asset_hierarchy in asset.asset_hierarchies() { + println!(" ID: {}", asset_hierarchy.id().unwrap_or("missing ID")); + println!(" Name: {}", asset_hierarchy.name()); } println!(" Assets Properties:"); - for asset_property in asset.asset_properties().unwrap() { + for asset_property in asset.asset_properties() { println!( " Alias: {}", asset_property.alias().unwrap_or_default() ); - println!( - " Data Type: {}", - asset_property.data_type().unwrap().as_str() - ); + println!(" Data Type: {}", asset_property.data_type().as_str()); println!( " Data Type Spec: {}", asset_property.data_type_spec().unwrap_or_default() ); - println!(" ID: {}", asset_property.id().unwrap_or_default()); - println!(" Name: {}", asset_property.name().unwrap_or_default()); + println!(" ID: {}", asset_property.id()); + println!(" Name: {}", asset_property.name()); println!( " Notification State: {}", asset_property @@ -91,18 +85,10 @@ async fn list_assets(client: &Client, asset_id: Option) -> Result<(), Er .unwrap() .state() .as_ref() - .unwrap() - .as_str() ); println!( " Notification Topic: {}", - asset_property - .notification() - .as_ref() - .unwrap() - .topic() - .as_ref() - .unwrap() + asset_property.notification().as_ref().unwrap().topic() ); println!( " Unit: {}", @@ -117,45 +103,26 @@ async fn list_assets(client: &Client, asset_id: Option) -> Result<(), Er " Description: {}", asset_composite_model.description().unwrap_or_default() ); - println!( - " Name: {}", - asset_composite_model.name().unwrap_or_default() - ); + println!(" Name: {}", asset_composite_model.name()); println!(" Properties:"); - for property in asset_composite_model.properties().unwrap() { + for property in asset_composite_model.properties() { println!(" Alias: {}", property.alias().unwrap_or_default()); - println!( - " Data Type: {}", - property.data_type().unwrap().as_str() - ); + println!(" Data Type: {}", property.data_type().as_str()); println!( " Data Type Spec: {}", property.data_type_spec().unwrap_or_default() ); - println!(" ID: {}", property.id.as_deref().unwrap_or_default()); - println!(" Name: {}", property.name().unwrap_or_default()); + println!(" ID: {}", property.id()); + println!(" Name: {}", property.name()); println!( " Notification State: {}", - property - .notification() - .as_ref() - .unwrap() - .state() - .as_ref() - .unwrap() - .as_str() + property.notification().as_ref().unwrap().state().as_str() ); println!( " Notification Topic: {}", - property - .notification() - .as_ref() - .unwrap() - .topic() - .as_ref() - .unwrap() + property.notification().as_ref().unwrap().topic() ); println!(" Unit: {}", property.unit().unwrap_or_default()); } diff --git a/rust_dev_preview/examples/sitewise/src/bin/list-asset-models.rs b/rust_dev_preview/examples/sitewise/src/bin/list-asset-models.rs index bae5a04f2d4..725716716c0 100644 --- a/rust_dev_preview/examples/sitewise/src/bin/list-asset-models.rs +++ b/rust_dev_preview/examples/sitewise/src/bin/list-asset-models.rs @@ -31,25 +31,22 @@ async fn list_asset_models(client: &Client) -> Result<(), Error> { println!("Asset Models:"); - for asset in resp.asset_model_summaries.unwrap() { - println!(" ID: {}", asset.id().unwrap_or_default()); - println!(" ARN: {}", asset.arn().unwrap_or_default()); - println!(" Name: {}", asset.name().unwrap_or_default()); - println!( - " Description: {}", - asset.description().unwrap_or_default() - ); + for asset in resp.asset_model_summaries { + println!(" ID: {}", asset.id()); + println!(" ARN: {}", asset.arn()); + println!(" Name: {}", asset.name()); + println!(" Description: {}", asset.description()); println!( " Creation Date: {}", - asset.creation_date().unwrap().to_chrono_utc()? + asset.creation_date().to_chrono_utc()? ); println!( " Last Update Date: {}", - asset.last_update_date().unwrap().to_chrono_utc()? + asset.last_update_date().to_chrono_utc()? ); println!( " Current Status: {}", - asset.status().unwrap().state().unwrap().as_str() + asset.status().unwrap().state().as_str() ); println!(); diff --git a/rust_dev_preview/examples/sitewise/src/bin/list-assets.rs b/rust_dev_preview/examples/sitewise/src/bin/list-assets.rs index 8793d882845..1fc7438d3cd 100644 --- a/rust_dev_preview/examples/sitewise/src/bin/list-assets.rs +++ b/rust_dev_preview/examples/sitewise/src/bin/list-assets.rs @@ -48,38 +48,32 @@ async fn list_assets( println!("Assets:"); - for asset in resp.asset_summaries.unwrap() { - println!(" ID: {}", asset.id.as_deref().unwrap_or_default()); - println!(" ARN: {}", asset.arn.as_deref().unwrap_or_default()); - println!(" Name: {}", asset.name.as_deref().unwrap_or_default()); - println!( - " Asset Model ID: {}", - asset.asset_model_id.as_deref().unwrap_or_default() - ); + for asset in resp.asset_summaries { + println!(" ID: {}", asset.id()); + println!(" ARN: {}", asset.arn()); + println!(" Name: {}", asset.name()); + println!(" Asset Model ID: {}", asset.asset_model_id()); println!( " Creation Date: {}", - asset.creation_date.unwrap().to_chrono_utc()? + asset.creation_date.to_chrono_utc()? ); println!( " Last Update Date: {}", - asset.last_update_date.unwrap().to_chrono_utc()? + asset.last_update_date.to_chrono_utc()? ); println!( " Current Status: {}", - asset.status.unwrap().state.unwrap().as_str() + asset.status.unwrap().state.as_str() ); println!(" Assets Hierarchies:"); - for hierarchy in asset.hierarchies.unwrap() { + for hierarchy in asset.hierarchies { println!( " Hierarchy ID: {}", - hierarchy.id.as_deref().unwrap_or_default() - ); - println!( - " Hierarchy Name: {}", - hierarchy.name.as_deref().unwrap_or_default() + hierarchy.id().unwrap_or("unknown id") ); + println!(" Hierarchy Name: {}", hierarchy.name()); } println!(); diff --git a/rust_dev_preview/examples/sitewise/src/bin/list-portals.rs b/rust_dev_preview/examples/sitewise/src/bin/list-portals.rs index ba07a307187..bde90551417 100644 --- a/rust_dev_preview/examples/sitewise/src/bin/list-portals.rs +++ b/rust_dev_preview/examples/sitewise/src/bin/list-portals.rs @@ -31,10 +31,10 @@ async fn list_portals(client: &Client) -> Result<(), Error> { println!("Portals:"); - for asset in resp.portal_summaries.unwrap() { - println!(" ID: {}", asset.id().unwrap_or_default()); - println!(" Role ARN: {}", asset.role_arn().unwrap_or_default()); - println!(" Name: {}", asset.name().unwrap_or_default()); + for asset in resp.portal_summaries().unwrap() { + println!(" ID: {}", asset.id()); + println!(" Role ARN: {}", asset.role_arn().unwrap_or("missing arn")); + println!(" Name: {}", asset.name()); println!( " Description: {}", asset.description().unwrap_or_default() @@ -47,10 +47,10 @@ async fn list_portals(client: &Client) -> Result<(), Error> { " Last Update Date: {}", asset.last_update_date().unwrap().to_chrono_utc()? ); - println!(" Start Url: {}", asset.start_url().unwrap_or_default()); + println!(" Start Url: {}", asset.start_url()); println!( " Current Status: {}", - asset.status().unwrap().state().unwrap().as_str() + asset.status().unwrap().state().as_str() ); println!(); diff --git a/rust_dev_preview/examples/textract/Cargo.toml b/rust_dev_preview/examples/textract/Cargo.toml index 225f4a7618b..42c79387869 100644 --- a/rust_dev_preview/examples/textract/Cargo.toml +++ b/rust_dev_preview/examples/textract/Cargo.toml @@ -14,3 +14,5 @@ aws-sdk-textract = { git = "https://github.com/awslabs/aws-sdk-rust", branch = " tokio = { version = "1.27", features = ["full"] } structopt = { version = "0.3", default-features = false } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } +thiserror = "1.0.49" +aws-types = "0.56.1" diff --git a/rust_dev_preview/examples/textract/src/bin/analyze-document.rs b/rust_dev_preview/examples/textract/src/bin/analyze-document.rs index 0bcffb3c301..f9c95dad37a 100644 --- a/rust_dev_preview/examples/textract/src/bin/analyze-document.rs +++ b/rust_dev_preview/examples/textract/src/bin/analyze-document.rs @@ -32,7 +32,7 @@ struct Opt { #[tokio::main] #[allow(clippy::result_large_err)] -async fn main() -> Result<(), aws_sdk_textract::Error> { +async fn main() { tracing_subscriber::fmt::init(); let Opt { region, @@ -53,12 +53,17 @@ async fn main() -> Result<(), aws_sdk_textract::Error> { .feature_types(FeatureType::Queries) .queries_config( QueriesConfig::builder() - .queries(Query::builder().text(&query).build()) - .build(), + .queries( + Query::builder() + .text(&query) + .build() + .expect("Failed to build query"), + ) + .build() + .expect("Failed to build query config"), ) .send() - .await - .map_err(Box::new); + .await; match res { Ok(analyze_output) => { @@ -82,7 +87,5 @@ async fn main() -> Result<(), aws_sdk_textract::Error> { DisplayErrorContext(&err) ); } - } - - Ok(()) + }; } diff --git a/rust_dev_preview/lambda/calculator/Cargo.toml b/rust_dev_preview/lambda/calculator/Cargo.toml index d47f1eebb20..120ed2fe232 100644 --- a/rust_dev_preview/lambda/calculator/Cargo.toml +++ b/rust_dev_preview/lambda/calculator/Cargo.toml @@ -2,7 +2,7 @@ name = "example-lambda-calculator" version = "0.1.0" authors = [ - "David Souther ", + "David Souther ", ] edition = "2021"