-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up re-exports and improve 'BuildError' conversions (#3173)
## Motivation and Context - Fixes #3171 - Fixes #3155 - Fixes #3172 ## Description - Add `configReExport` to make it easy and consistent to re-export types into the config module when they are used! - Add this for a bunch of types and clean up some (now) dead code - Re export `BuildError` - Enable converting from `BuildError` into `SdkError` There are probably more places this can be used, but I'd like to keep this change small to facilitate easy backport to 0.57. ## Testing CI ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [x] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates - [x] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
- Loading branch information
Showing
17 changed files
with
186 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
use aws_sdk_dynamodb::error::SdkError; | ||
use aws_sdk_dynamodb::operation::create_table::CreateTableError; | ||
use aws_sdk_dynamodb::types::{KeySchemaElement, KeyType}; | ||
use aws_sdk_dynamodb::Client; | ||
|
||
#[allow(dead_code)] | ||
async fn create_table_test(client: &Client) -> Result<(), SdkError<CreateTableError>> { | ||
let _just_checking_compilation = client | ||
.create_table() | ||
.table_name("test") | ||
.key_schema( | ||
KeySchemaElement::builder() | ||
.attribute_name("year") | ||
.key_type(KeyType::Hash) | ||
.build()?, | ||
) | ||
.send() | ||
.await; | ||
Ok(()) | ||
} | ||
|
||
#[allow(dead_code)] | ||
async fn create_table_test_super_error(client: &Client) -> Result<(), aws_sdk_dynamodb::Error> { | ||
let _just_checking_compilation = client | ||
.create_table() | ||
.table_name("test") | ||
.key_schema( | ||
KeySchemaElement::builder() | ||
.attribute_name("year") | ||
.key_type(KeyType::Hash) | ||
.build()?, | ||
) | ||
.send() | ||
.await; | ||
Ok(()) | ||
} |
17 changes: 17 additions & 0 deletions
17
...ient/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientReExports.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package software.amazon.smithy.rust.codegen.client.smithy | ||
|
||
import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate | ||
import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType | ||
|
||
/** Returns a symbol for a type re-exported into crate::config | ||
* Although it is not always possible to use this, this is the preferred method for using types in config customizations | ||
* and ensures that your type will be re-exported if it is used. | ||
*/ | ||
fun configReexport(type: RuntimeType): RuntimeType = RuntimeType.forInlineFun(type.name, module = ClientRustModule.config) { | ||
rustTemplate("pub use #{type};", "type" to type) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.