diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt index d16bcce33a..d5ba3b4349 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsFluentClientDecorator.kt @@ -9,8 +9,9 @@ import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.model.traits.TitleTrait import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext +import software.amazon.smithy.rust.codegen.client.smithy.ClientRustModule import software.amazon.smithy.rust.codegen.client.smithy.customize.ClientCodegenDecorator -import software.amazon.smithy.rust.codegen.client.smithy.generators.client.CustomizableOperationGenerator +import software.amazon.smithy.rust.codegen.client.smithy.featureGatedCustomizeModule import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientGenerator import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientGenerics @@ -102,10 +103,10 @@ class AwsFluentClientDecorator : ClientCodegenDecorator { ), retryClassifier = AwsRuntimeType.awsHttp(runtimeConfig).resolve("retry::AwsResponseRetryClassifier"), ).render(rustCrate) - rustCrate.withModule(CustomizableOperationGenerator.CustomizeModule) { + rustCrate.withModule(codegenContext.featureGatedCustomizeModule()) { renderCustomizableOperationSendMethod(runtimeConfig, generics, this) } - rustCrate.withModule(FluentClientGenerator.clientModule) { + rustCrate.withModule(ClientRustModule.client) { AwsFluentClientExtensions(types).render(this) } val awsSmithyClient = "aws-smithy-client" diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/BaseRequestIdDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/BaseRequestIdDecorator.kt index a3a991bedf..de51f8a164 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/BaseRequestIdDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/BaseRequestIdDecorator.kt @@ -7,10 +7,10 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext +import software.amazon.smithy.rust.codegen.client.smithy.ClientRustModule import software.amazon.smithy.rust.codegen.client.smithy.customize.ClientCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.error.ErrorCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.error.ErrorSection -import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock @@ -66,7 +66,7 @@ abstract class BaseRequestIdDecorator : ClientCodegenDecorator { ): List = baseCustomizations + listOf(RequestIdBuilderCustomization()) override fun extras(codegenContext: ClientCodegenContext, rustCrate: RustCrate) { - rustCrate.withModule(RustModule.Types) { + rustCrate.withModule(ClientRustModule.Types) { // Re-export RequestId in generated crate rust("pub use #T;", accessorTrait(codegenContext)) } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt index c9499c3920..30e15a0ca9 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt @@ -8,9 +8,9 @@ package software.amazon.smithy.rustsdk import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.ClientCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.customize.TestUtilFeature +import software.amazon.smithy.rust.codegen.client.smithy.featureGatedConfigModule import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig -import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable @@ -19,8 +19,6 @@ import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.customize.AdHocCustomization import software.amazon.smithy.rust.codegen.core.smithy.customize.adhocCustomization -import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization -import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection class CredentialsProviderDecorator : ClientCodegenDecorator { override val name: String = "CredentialsProvider" @@ -33,13 +31,6 @@ class CredentialsProviderDecorator : ClientCodegenDecorator { return baseCustomizations + CredentialProviderConfig(codegenContext.runtimeConfig) } - override fun libRsCustomizations( - codegenContext: ClientCodegenContext, - baseCustomizations: List, - ): List { - return baseCustomizations + PubUseCredentials(codegenContext.runtimeConfig) - } - override fun extraSections(codegenContext: ClientCodegenContext): List = listOf( adhocCustomization { section -> @@ -49,6 +40,13 @@ class CredentialsProviderDecorator : ClientCodegenDecorator { override fun extras(codegenContext: ClientCodegenContext, rustCrate: RustCrate) { rustCrate.mergeFeature(TestUtilFeature.copy(deps = listOf("aws-credential-types/test-util"))) + + rustCrate.withModule(codegenContext.featureGatedConfigModule()) { + rust( + "pub use #T::Credentials;", + AwsRuntimeType.awsCredentialTypes(codegenContext.runtimeConfig), + ) + } } } @@ -95,20 +93,5 @@ class CredentialProviderConfig(runtimeConfig: RuntimeConfig) : ConfigCustomizati } } -class PubUseCredentials(private val runtimeConfig: RuntimeConfig) : LibRsCustomization() { - override fun section(section: LibRsSection): Writable { - return when (section) { - is LibRsSection.Body -> writable { - rust( - "pub use #T::Credentials;", - AwsRuntimeType.awsCredentialTypes(runtimeConfig), - ) - } - - else -> emptySection - } - } -} - fun defaultProvider() = RuntimeType.forInlineDependency(InlineAwsDependency.forRustFile("no_credentials")).resolve("NoCredentials") diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt index 70775e2cda..ab37a9d598 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RegionDecorator.kt @@ -12,6 +12,7 @@ import software.amazon.smithy.rulesengine.language.syntax.parameters.Parameter import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.ClientCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.endpoint.EndpointCustomization +import software.amazon.smithy.rust.codegen.client.smithy.featureGatedConfigModule import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig import software.amazon.smithy.rust.codegen.core.rustlang.Writable @@ -20,12 +21,11 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig +import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.customize.AdHocCustomization import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.smithy.customize.adhocCustomization -import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization -import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection import software.amazon.smithy.rust.codegen.core.util.dq import software.amazon.smithy.rust.codegen.core.util.extendIf import software.amazon.smithy.rust.codegen.core.util.thenSingletonListOf @@ -101,13 +101,6 @@ class RegionDecorator : ClientCodegenDecorator { return baseCustomizations.extendIf(usesRegion(codegenContext)) { RegionConfigPlugin() } } - override fun libRsCustomizations( - codegenContext: ClientCodegenContext, - baseCustomizations: List, - ): List { - return baseCustomizations.extendIf(usesRegion(codegenContext)) { PubUseRegion(codegenContext.runtimeConfig) } - } - override fun extraSections(codegenContext: ClientCodegenContext): List { return usesRegion(codegenContext).thenSingletonListOf { adhocCustomization { section -> @@ -121,6 +114,14 @@ class RegionDecorator : ClientCodegenDecorator { } } + override fun extras(codegenContext: ClientCodegenContext, rustCrate: RustCrate) { + if (usesRegion(codegenContext)) { + rustCrate.withModule(codegenContext.featureGatedConfigModule()) { + rust("pub use #T::Region;", region(codegenContext.runtimeConfig)) + } + } + } + override fun endpointCustomizations(codegenContext: ClientCodegenContext): List { if (!usesRegion(codegenContext)) { return listOf() @@ -221,19 +222,4 @@ class RegionConfigPlugin : OperationCustomization() { } } -class PubUseRegion(private val runtimeConfig: RuntimeConfig) : LibRsCustomization() { - override fun section(section: LibRsSection): Writable { - return when (section) { - is LibRsSection.Body -> writable { - rust( - "pub use #T::Region;", - region(runtimeConfig), - ) - } - - else -> emptySection - } - } -} - fun region(runtimeConfig: RuntimeConfig) = AwsRuntimeType.awsTypes(runtimeConfig).resolve("region") diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/AwsEndpointDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/AwsEndpointDecorator.kt index ab9ce5bf1f..7c1de7e013 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/AwsEndpointDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/endpoints/AwsEndpointDecorator.kt @@ -18,6 +18,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.ClientCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.endpoint.EndpointTypesGenerator import software.amazon.smithy.rust.codegen.client.smithy.endpoint.generators.EndpointsModule +import software.amazon.smithy.rust.codegen.client.smithy.featureGatedConfigModule import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig import software.amazon.smithy.rust.codegen.core.rustlang.Attribute @@ -27,12 +28,9 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext -import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.customize.AdHocCustomization import software.amazon.smithy.rust.codegen.core.smithy.customize.adhocCustomization -import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsCustomization -import software.amazon.smithy.rust.codegen.core.smithy.generators.LibRsSection import software.amazon.smithy.rust.codegen.core.util.extendIf import software.amazon.smithy.rust.codegen.core.util.letIf import software.amazon.smithy.rust.codegen.core.util.thenSingletonListOf @@ -91,14 +89,14 @@ class AwsEndpointDecorator : ClientCodegenDecorator { } } - override fun libRsCustomizations( - codegenContext: ClientCodegenContext, - baseCustomizations: List, - ): List { - return baseCustomizations + PubUseEndpoint(codegenContext.runtimeConfig) - } - override fun extras(codegenContext: ClientCodegenContext, rustCrate: RustCrate) { + rustCrate.withModule(codegenContext.featureGatedConfigModule()) { + rust( + "pub use #T::endpoint::Endpoint;", + CargoDependency.smithyHttp(codegenContext.runtimeConfig).toType(), + ) + } + val epTypes = EndpointTypesGenerator.fromContext(codegenContext) if (epTypes.defaultResolver() == null) { throw CodegenException( @@ -257,21 +255,6 @@ class AwsEndpointDecorator : ClientCodegenDecorator { } } } - - class PubUseEndpoint(private val runtimeConfig: RuntimeConfig) : LibRsCustomization() { - override fun section(section: LibRsSection): Writable { - return when (section) { - is LibRsSection.Body -> writable { - rust( - "pub use #T::endpoint::Endpoint;", - CargoDependency.smithyHttp(runtimeConfig).toType(), - ) - } - - else -> emptySection - } - } - } } fun ClientCodegenContext.isRegionalized() = getBuiltIn(Builtins.REGION) != null diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustModule.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustModule.kt index 53fe9c6921..8e432af6e4 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustModule.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustModule.kt @@ -20,6 +20,9 @@ import software.amazon.smithy.rust.codegen.core.util.hasTrait * Modules for code generated client crates. */ object ClientRustModule { + /** crate */ + val root = RustModule.LibRs + /** crate::client */ val client = Client.self object Client { @@ -57,3 +60,19 @@ object ClientModuleProvider : ModuleProvider { override fun moduleForEventStreamError(eventStream: UnionShape): RustModule.LeafModule = ClientRustModule.Error } + +// TODO(CrateReorganization): Remove when cleaning up `enableNewCrateOrganizationScheme` +fun ClientCodegenContext.featureGatedConfigModule() = when (settings.codegenConfig.enableNewCrateOrganizationScheme) { + true -> ClientRustModule.Config + else -> ClientRustModule.root +} + +// TODO(CrateReorganization): Remove when cleaning up `enableNewCrateOrganizationScheme` +fun ClientCodegenContext.featureGatedCustomizeModule() = when (settings.codegenConfig.enableNewCrateOrganizationScheme) { + true -> ClientRustModule.Client.customize + else -> RustModule.public( + "customize", + "Operation customization and supporting types", + parent = ClientRustModule.Operation, + ) +} diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ClientEnumGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ClientEnumGenerator.kt index b4c988dc6b..36f5a1c19d 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ClientEnumGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/ClientEnumGenerator.kt @@ -6,6 +6,7 @@ package software.amazon.smithy.rust.codegen.client.smithy.generators import software.amazon.smithy.model.shapes.StringShape +import software.amazon.smithy.rust.codegen.client.smithy.ClientRustModule import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.Writable @@ -86,7 +87,7 @@ data class InfallibleEnumType( } private fun unknownVariantValue(context: EnumGeneratorContext): RuntimeType { - return RuntimeType.forInlineFun(UnknownVariantValue, RustModule.Types) { + return RuntimeType.forInlineFun(UnknownVariantValue, ClientRustModule.Types) { docs( """ Opaque struct used as inner data for the `Unknown` variant defined in enums in @@ -167,4 +168,4 @@ data class InfallibleEnumType( } class ClientEnumGenerator(codegenContext: CodegenContext, shape: StringShape) : - EnumGenerator(codegenContext.model, codegenContext.symbolProvider, shape, InfallibleEnumType(RustModule.Types)) + EnumGenerator(codegenContext.model, codegenContext.symbolProvider, shape, InfallibleEnumType(ClientRustModule.Types)) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/CustomizableOperationGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/CustomizableOperationGenerator.kt index 31a86d07ac..31f2ee8f58 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/CustomizableOperationGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/CustomizableOperationGenerator.kt @@ -5,14 +5,13 @@ package software.amazon.smithy.rust.codegen.client.smithy.generators.client +import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext +import software.amazon.smithy.rust.codegen.client.smithy.featureGatedCustomizeModule import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.GenericTypeArg import software.amazon.smithy.rust.codegen.core.rustlang.RustGenerics -import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.core.rustlang.Visibility import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate -import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.RustCrate @@ -21,20 +20,16 @@ import software.amazon.smithy.rust.codegen.core.smithy.RustCrate * fluent client builders. */ class CustomizableOperationGenerator( - private val runtimeConfig: RuntimeConfig, + private val codegenContext: ClientCodegenContext, private val generics: FluentClientGenerics, - private val includeFluentClient: Boolean, ) { - - companion object { - val CustomizeModule = RustModule.public("customize", "Operation customization and supporting types", parent = RustModule.operation(Visibility.PUBLIC)) - } - + private val includeFluentClient = codegenContext.settings.codegenConfig.includeFluentClient + private val runtimeConfig = codegenContext.runtimeConfig private val smithyHttp = CargoDependency.smithyHttp(runtimeConfig).toType() private val smithyTypes = CargoDependency.smithyTypes(runtimeConfig).toType() fun render(crate: RustCrate) { - crate.withModule(CustomizeModule) { + crate.withModule(codegenContext.featureGatedCustomizeModule()) { rustTemplate( """ pub use #{Operation}; @@ -67,6 +62,7 @@ class CustomizableOperationGenerator( "handle_generics_bounds" to handleGenerics.bounds(), "operation_generics_decl" to operationGenerics.declaration(), "combined_generics_decl" to combinedGenerics.declaration(), + "customize_module" to codegenContext.featureGatedCustomizeModule(), ) writer.rustTemplate( @@ -81,7 +77,7 @@ class CustomizableOperationGenerator( /// A wrapper type for [`Operation`](aws_smithy_http::operation::Operation)s that allows for /// customization of the operation before it is sent. A `CustomizableOperation` may be sent - /// by calling its [`.send()`][crate::operation::customize::CustomizableOperation::send] method. + /// by calling its [`.send()`][#{customize_module}::CustomizableOperation::send] method. ##[derive(Debug)] pub struct CustomizableOperation#{combined_generics_decl:W} { pub(crate) handle: Arc, diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt index b43ad4ba73..3b8c473849 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt @@ -13,6 +13,8 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.traits.DocumentationTrait import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext +import software.amazon.smithy.rust.codegen.client.smithy.ClientRustModule +import software.amazon.smithy.rust.codegen.client.smithy.featureGatedCustomizeModule import software.amazon.smithy.rust.codegen.client.smithy.generators.PaginatorGenerator import software.amazon.smithy.rust.codegen.client.smithy.generators.isPaginated import software.amazon.smithy.rust.codegen.core.rustlang.Attribute @@ -65,11 +67,6 @@ class FluentClientGenerator( companion object { fun clientOperationFnName(operationShape: OperationShape, symbolProvider: RustSymbolProvider): String = RustReservedWords.escapeIfNeeded(symbolProvider.toSymbol(operationShape).name.toSnakeCase()) - - val clientModule = RustModule.public( - "client", - "Client and fluent builders for calling the service.", - ) } private val serviceShape = codegenContext.serviceShape @@ -81,15 +78,11 @@ class FluentClientGenerator( private val core = FluentClientCore(model) fun render(crate: RustCrate) { - crate.withModule(clientModule) { + crate.withModule(ClientRustModule.client) { renderFluentClient(this) } - CustomizableOperationGenerator( - runtimeConfig, - generics, - codegenContext.settings.codegenConfig.includeFluentClient, - ).render(crate) + CustomizableOperationGenerator(codegenContext, generics).render(crate) } private fun renderFluentClient(writer: RustWriter) { @@ -278,7 +271,7 @@ class FluentClientGenerator( /// Consume this builder, creating a customizable operation that can be modified before being /// sent. The operation's inner [http::Request] can be modified as well. pub async fn customize(self) -> std::result::Result< - crate::operation::customize::CustomizableOperation#{customizable_op_type_params:W}, + #{CustomizableOperation}#{customizable_op_type_params:W}, #{SdkError}<#{OperationError}> > #{send_bounds:W} { let handle = self.handle.clone(); @@ -286,7 +279,7 @@ class FluentClientGenerator( .make_operation(&handle.conf) .await .map_err(#{SdkError}::construction_failure)?; - Ok(crate::operation::customize::CustomizableOperation { handle, operation }) + Ok(#{CustomizableOperation} { handle, operation }) } /// Sends the request and returns the response. @@ -306,6 +299,8 @@ class FluentClientGenerator( self.handle.client.call(op).await } """, + "CustomizableOperation" to codegenContext.featureGatedCustomizeModule().toType() + .resolve("CustomizableOperation"), "ClassifyRetry" to RuntimeType.classifyRetry(runtimeConfig), "OperationError" to errorType, "OperationOutput" to outputType, diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustModule.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustModule.kt index d98102d80b..ef2786a396 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustModule.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustModule.kt @@ -99,12 +99,6 @@ sealed class RustModule { parent = parent, ).cfgTest() - // TODO(https://github.com/awslabs/smithy-rs/pull/2129): Remove once #2129 merges - val Error = public("error", documentation = "All error types that operations can return. Documentation on these types is copied from the model.") - - // TODO(https://github.com/awslabs/smithy-rs/pull/2334): Remove once #2334 merges - val Types = public("types", documentation = "Data primitives referenced by other data types.") - /** * Helper method to generate the `operation` Rust module. * Its visibility depends on the generation context (client or server). diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriter.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriter.kt index 67eb7f4b7a..553e30205e 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriter.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriter.kt @@ -705,6 +705,10 @@ class RustWriter private constructor( t.fullyQualifiedName() } + is RustModule -> { + t.fullyQualifiedPath() + } + is Symbol -> { addDepsRecursively(t) t.rustType().render(fullyQualified = true) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/EventStreamSymbolProvider.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/EventStreamSymbolProvider.kt index 9a75974d24..d1c3afd9f4 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/EventStreamSymbolProvider.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/EventStreamSymbolProvider.kt @@ -10,9 +10,7 @@ import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.MemberShape import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.Shape -import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.core.rustlang.RustModule import software.amazon.smithy.rust.codegen.core.rustlang.RustType import software.amazon.smithy.rust.codegen.core.rustlang.render import software.amazon.smithy.rust.codegen.core.rustlang.stripOuter @@ -24,11 +22,6 @@ import software.amazon.smithy.rust.codegen.core.util.isEventStream import software.amazon.smithy.rust.codegen.core.util.isInputEventStream import software.amazon.smithy.rust.codegen.core.util.isOutputEventStream -fun UnionShape.eventStreamErrorSymbol(symbolProvider: RustSymbolProvider): RuntimeType { - val unionSymbol = symbolProvider.toSymbol(this) - return RustModule.Error.toType().resolve("${unionSymbol.name}Error") -} - /** * Wrapping symbol provider to wrap modeled types with the aws-smithy-http Event Stream send/receive types. */