diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsEndpointDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsEndpointDecorator.kt index d82cadd104..88194161d7 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsEndpointDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsEndpointDecorator.kt @@ -20,7 +20,6 @@ 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.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate @@ -95,18 +94,18 @@ class EndpointConfigCustomization( ) : ConfigCustomization() { private val runtimeConfig = codegenContext.runtimeConfig - private val resolveAwsEndpoint = runtimeConfig.awsEndpoint().asType().copy(name = "ResolveAwsEndpoint") + private val resolveAwsEndpoint = runtimeConfig.awsEndpoint().toType().copy(name = "ResolveAwsEndpoint") private val smithyEndpointResolver = - CargoDependency.SmithyHttp(runtimeConfig).asType().member("endpoint::ResolveEndpoint") - private val placeholderEndpointParams = runtimeConfig.awsEndpoint().asType().member("Params") - private val endpointShim = runtimeConfig.awsEndpoint().asType().member("EndpointShim") + CargoDependency.smithyHttp(runtimeConfig).toType().member("endpoint::ResolveEndpoint") + private val placeholderEndpointParams = runtimeConfig.awsEndpoint().toType().member("Params") + private val endpointShim = runtimeConfig.awsEndpoint().toType().member("EndpointShim") private val moduleUseName = codegenContext.moduleUseName() private val codegenScope = arrayOf( "SmithyResolver" to smithyEndpointResolver, "PlaceholderParams" to placeholderEndpointParams, "ResolveAwsEndpoint" to resolveAwsEndpoint, "EndpointShim" to endpointShim, - "aws_types" to awsTypes(runtimeConfig).asType(), + "aws_types" to awsTypes(runtimeConfig).toType(), ) override fun section(section: ServiceConfig): Writable = writable { @@ -184,7 +183,7 @@ class EndpointConfigCustomization( class EndpointResolverFeature(private val runtimeConfig: RuntimeConfig, private val operationShape: OperationShape) : OperationCustomization() { - private val placeholderEndpointParams = runtimeConfig.awsEndpoint().asType().member("Params") + private val placeholderEndpointParams = runtimeConfig.awsEndpoint().toType().member("Params") private val codegenScope = arrayOf( "PlaceholderParams" to placeholderEndpointParams, "BuildError" to runtimeConfig.operationBuildError(), @@ -215,7 +214,7 @@ class PubUseEndpoint(private val runtimeConfig: RuntimeConfig) : LibRsCustomizat is LibRsSection.Body -> writable { rust( "pub use #T::endpoint::Endpoint;", - CargoDependency.SmithyHttp(runtimeConfig).asType(), + CargoDependency.smithyHttp(runtimeConfig).toType(), ) } else -> emptySection @@ -226,8 +225,8 @@ class PubUseEndpoint(private val runtimeConfig: RuntimeConfig) : LibRsCustomizat class EndpointResolverGenerator(codegenContext: CodegenContext, private val endpointData: ObjectNode) { private val runtimeConfig = codegenContext.runtimeConfig private val endpointPrefix = codegenContext.serviceShape.expectTrait().endpointPrefix - private val awsEndpoint = runtimeConfig.awsEndpoint().asType() - private val awsTypes = runtimeConfig.awsTypes().asType() + private val awsEndpoint = runtimeConfig.awsEndpoint().toType() + private val awsTypes = runtimeConfig.awsTypes().toType() private val codegenScope = arrayOf( "Partition" to awsEndpoint.member("Partition"), 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 068ad8999b..3a9662d869 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 @@ -24,7 +24,6 @@ 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.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate @@ -39,13 +38,13 @@ import software.amazon.smithy.rust.codegen.core.util.expectTrait import software.amazon.smithy.rustsdk.AwsRuntimeType.defaultMiddleware private class Types(runtimeConfig: RuntimeConfig) { - private val smithyTypesDep = CargoDependency.SmithyTypes(runtimeConfig) - private val smithyClientDep = CargoDependency.SmithyClient(runtimeConfig) - private val smithyHttpDep = CargoDependency.SmithyHttp(runtimeConfig) + private val smithyTypesDep = CargoDependency.smithyTypes(runtimeConfig) + private val smithyClientDep = CargoDependency.smithyClient(runtimeConfig) + private val smithyHttpDep = CargoDependency.smithyHttp(runtimeConfig) - val awsTypes = awsTypes(runtimeConfig).asType() + val awsTypes = awsTypes(runtimeConfig).toType() val smithyClientRetry = RuntimeType("retry", smithyClientDep, "aws_smithy_client") - val awsSmithyClient = smithyClientDep.asType() + val awsSmithyClient = smithyClientDep.toType() val connectorSettings = RuntimeType("ConnectorSettings", smithyClientDep, "aws_smithy_client::http_connector") val defaultMiddleware = runtimeConfig.defaultMiddleware() @@ -106,7 +105,7 @@ class AwsFluentClientDecorator : RustCodegenDecorator writable { rust( "pub use #T::Credentials;", - awsTypes(runtimeConfig).asType(), + awsTypes(runtimeConfig).toType(), ) } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpConnectorConfigCustomization.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpConnectorConfigCustomization.kt index 1957d5a208..6184c5331d 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpConnectorConfigCustomization.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpConnectorConfigCustomization.kt @@ -10,9 +10,8 @@ import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDe 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.client.smithy.generators.protocol.ClientProtocolGenerator -import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.SmithyClient +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.smithyClient import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType 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 @@ -39,7 +38,7 @@ class HttpConnectorConfigCustomization( private val runtimeConfig = codegenContext.runtimeConfig private val moduleUseName = codegenContext.moduleUseName() private val codegenScope = arrayOf( - "HttpConnector" to SmithyClient(runtimeConfig).asType().member("http_connector::HttpConnector"), + "HttpConnector" to smithyClient(runtimeConfig).toType().member("http_connector::HttpConnector"), ) override fun section(section: ServiceConfig): Writable { diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpRequestChecksumDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpRequestChecksumDecorator.kt index d89e2868ac..8642170205 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpRequestChecksumDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/HttpRequestChecksumDecorator.kt @@ -13,7 +13,6 @@ import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.Cli import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.Visibility import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType 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.smithy.CodegenContext @@ -32,9 +31,9 @@ fun RuntimeConfig.awsInlineableBodyWithChecksum() = RuntimeType.forInlineDepende "http_body_checksum", visibility = Visibility.PUBLIC, CargoDependency.Http, CargoDependency.HttpBody, - CargoDependency.SmithyHttp(this), - CargoDependency.SmithyChecksums(this), - CargoDependency.SmithyTypes(this), + CargoDependency.smithyHttp(this), + CargoDependency.smithyChecksums(this), + CargoDependency.smithyTypes(this), CargoDependency.Bytes, CargoDependency.Tracing, this.sigAuth(), @@ -105,7 +104,7 @@ private fun HttpChecksumTrait.checksumAlgorithmToStr( }; """, "BuildError" to runtimeConfig.operationBuildError(), - "ChecksumAlgorithm" to CargoDependency.SmithyChecksums(runtimeConfig).asType().member("ChecksumAlgorithm"), + "ChecksumAlgorithm" to CargoDependency.smithyChecksums(runtimeConfig).toType().member("ChecksumAlgorithm"), ) // If a request checksum is not required and there's no way to set one, do nothing diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt index df68a0a041..424fb2cef0 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/IntegrationTestDependencies.kt @@ -9,9 +9,19 @@ import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.AsyncStd +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.AsyncStream import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.BytesUtils +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.Criterion +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.FuturesCore +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.FuturesUtil +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.Hound +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.SerdeJson +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.Smol import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.TempFile -import software.amazon.smithy.rust.codegen.core.rustlang.CratesIo +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.Tokio +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.Tracing +import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency.Companion.TracingSubscriber import software.amazon.smithy.rust.codegen.core.rustlang.DependencyScope import software.amazon.smithy.rust.codegen.core.rustlang.Writable import software.amazon.smithy.rust.codegen.core.rustlang.writable @@ -66,10 +76,10 @@ class IntegrationTestDependencies( override fun section(section: LibRsSection) = when (section) { is LibRsSection.Body -> writable { if (hasTests) { - val smithyClient = CargoDependency.SmithyClient(runtimeConfig) + val smithyClient = CargoDependency.smithyClient(runtimeConfig) .copy(features = setOf("test-util"), scope = DependencyScope.Dev) addDependency(smithyClient) - addDependency(CargoDependency.SmithyProtocolTestHelpers(runtimeConfig)) + addDependency(CargoDependency.smithyProtocolTestHelpers(runtimeConfig)) addDependency(SerdeJson) addDependency(Tokio) addDependency(FuturesUtil) @@ -88,7 +98,7 @@ class IntegrationTestDependencies( private fun serviceSpecificCustomizations(): List = when (moduleName) { "transcribestreaming" -> listOf(TranscribeTestDependencies()) - "s3" -> listOf(S3TestDependencies(runtimeConfig)) + "s3" -> listOf(S3TestDependencies()) else -> emptyList() } } @@ -102,30 +112,12 @@ class TranscribeTestDependencies : LibRsCustomization() { } } -class S3TestDependencies( - private val runtimeConfig: RuntimeConfig, -) : LibRsCustomization() { +class S3TestDependencies : LibRsCustomization() { override fun section(section: LibRsSection): Writable = writable { addDependency(AsyncStd) addDependency(BytesUtils) addDependency(Smol) addDependency(TempFile) - runtimeConfig.runtimeCrate("async", scope = DependencyScope.Dev) - runtimeConfig.runtimeCrate("client", scope = DependencyScope.Dev) - runtimeConfig.runtimeCrate("http", scope = DependencyScope.Dev) - runtimeConfig.runtimeCrate("types", scope = DependencyScope.Dev) } } - -private val AsyncStd = CargoDependency("async-std", CratesIo("1.12.0"), scope = DependencyScope.Dev) -private val AsyncStream = CargoDependency("async-stream", CratesIo("0.3.0"), DependencyScope.Dev) -private val Criterion = CargoDependency("criterion", CratesIo("0.4.0"), scope = DependencyScope.Dev) -private val FuturesCore = CargoDependency("futures-core", CratesIo("0.3.0"), DependencyScope.Dev) -private val FuturesUtil = CargoDependency("futures-util", CratesIo("0.3.0"), scope = DependencyScope.Dev) -private val Hound = CargoDependency("hound", CratesIo("3.4.0"), DependencyScope.Dev) -private val SerdeJson = CargoDependency("serde_json", CratesIo("1.0.0"), features = emptySet(), scope = DependencyScope.Dev) -private val Smol = CargoDependency("smol", CratesIo("1.2.0"), scope = DependencyScope.Dev) -private val Tokio = CargoDependency("tokio", CratesIo("1.8.4"), features = setOf("macros", "test-util"), scope = DependencyScope.Dev) -private val Tracing = CargoDependency("tracing", CratesIo("0.1.0"), scope = DependencyScope.Dev) -private val TracingSubscriber = CargoDependency("tracing-subscriber", CratesIo("0.3.15"), scope = DependencyScope.Dev, features = setOf("env-filter")) diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RetryClassifierDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RetryClassifierDecorator.kt index 4d1aa4973d..e1e784ce70 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RetryClassifierDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/RetryClassifierDecorator.kt @@ -9,7 +9,6 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.RustCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext @@ -35,7 +34,7 @@ class RetryClassifierDecorator : RustCodegenDecorator writable { rust( @@ -43,6 +42,7 @@ class RetryClassifierFeature(private val runtimeConfig: RuntimeConfig) : Operati retryType(), ) } + else -> emptySection } } diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkConfigDecorator.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkConfigDecorator.kt index eb7630d6c1..5d63aa4ee2 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkConfigDecorator.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkConfigDecorator.kt @@ -12,7 +12,6 @@ import software.amazon.smithy.rust.codegen.client.smithy.generators.config.Servi import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator 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.asType 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 @@ -38,7 +37,8 @@ class SdkConfigDecorator : RustCodegenDecorator("deleteSdk") { delete = setOf(outputDir) diff --git a/buildSrc/src/main/kotlin/aws/sdk/ServiceLoader.kt b/buildSrc/src/main/kotlin/aws/sdk/ServiceLoader.kt index 6393613093..bb99ff0251 100644 --- a/buildSrc/src/main/kotlin/aws/sdk/ServiceLoader.kt +++ b/buildSrc/src/main/kotlin/aws/sdk/ServiceLoader.kt @@ -5,6 +5,7 @@ package aws.sdk +import CrateSet import org.gradle.api.Project import software.amazon.smithy.aws.traits.ServiceTrait import software.amazon.smithy.model.Model diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProvider.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProvider.kt index 6802d444c4..85053dca6c 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProvider.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/EventStreamSymbolProvider.kt @@ -38,7 +38,7 @@ class EventStreamSymbolProvider( private val model: Model, private val target: CodegenTarget, ) : WrappingSymbolProvider(base) { - private val smithyEventStream = CargoDependency.SmithyEventStream(runtimeConfig) + private val smithyEventStream = CargoDependency.smithyEventStream(runtimeConfig) override fun toSymbol(shape: Shape): Symbol { val initial = super.toSymbol(shape) @@ -71,7 +71,7 @@ class EventStreamSymbolProvider( .name(rustType.name) .rustType(rustType) .addReference(initial) - .addDependency(CargoDependency.SmithyHttp(runtimeConfig).withFeature("event-stream")) + .addDependency(CargoDependency.smithyHttp(runtimeConfig).withFeature("event-stream")) .addReference(error) .build() } diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpChecksumRequiredGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpChecksumRequiredGenerator.kt index 75feb396f0..14cd2caf46 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpChecksumRequiredGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/HttpChecksumRequiredGenerator.kt @@ -10,7 +10,6 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.traits.HttpChecksumRequiredTrait import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType 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 @@ -50,8 +49,8 @@ class HttpChecksumRequiredGenerator( Result::<_, #{BuildError}>::Ok(req) })?; """, - "md5" to CargoDependency.Md5.asType(), - "http" to CargoDependency.Http.asType(), + "md5" to CargoDependency.Md5.toType(), + "http" to CargoDependency.Http.toType(), "base64_encode" to RuntimeType.Base64Encode(codegenContext.runtimeConfig), "BuildError" to codegenContext.runtimeConfig.operationBuildError(), ) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/SmithyTypesPubUseGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/SmithyTypesPubUseGenerator.kt index 1bd51e2222..4546a74154 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/SmithyTypesPubUseGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customizations/SmithyTypesPubUseGenerator.kt @@ -9,7 +9,6 @@ import software.amazon.smithy.model.Model import software.amazon.smithy.model.shapes.StructureShape 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.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType @@ -56,9 +55,9 @@ internal fun pubUseTypes(runtimeConfig: RuntimeConfig, model: Model): List + ) + CargoDependency.smithyTypes(runtimeConfig).toType().let { types -> listOf(PubUseType(types.member("error::display::DisplayErrorContext")) { true }) - } + CargoDependency.SmithyHttp(runtimeConfig).asType().let { http -> + } + CargoDependency.smithyHttp(runtimeConfig).toType().let { http -> listOf( PubUseType(http.member("result::SdkError")) { true }, PubUseType(http.member("byte_stream::ByteStream"), ::hasStreamingOperations), diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/NoOpEventStreamSigningDecorator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/NoOpEventStreamSigningDecorator.kt index f4cfce3898..8c63b06d72 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/NoOpEventStreamSigningDecorator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/NoOpEventStreamSigningDecorator.kt @@ -48,7 +48,7 @@ class NoOpEventStreamSigningConfig( private val serviceHasEventStream: Boolean, runtimeConfig: RuntimeConfig, ) : EventStreamSigningConfig(runtimeConfig) { - private val smithyEventStream = CargoDependency.SmithyEventStream(runtimeConfig) + private val smithyEventStream = CargoDependency.smithyEventStream(runtimeConfig) private val codegenScope = arrayOf( "NoOpSigner" to RuntimeType("NoOpSigner", smithyEventStream, "aws_smithy_eventstream::frame"), ) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RequiredCustomizations.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RequiredCustomizations.kt index 0567f3a13a..fd7239e7a0 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RequiredCustomizations.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/customize/RequiredCustomizations.kt @@ -19,7 +19,6 @@ import software.amazon.smithy.rust.codegen.client.smithy.customizations.pubUseSm import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.ClientProtocolGenerator import software.amazon.smithy.rust.codegen.core.rustlang.Feature -import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EndpointTraitBindingGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EndpointTraitBindingGenerator.kt index c5a99a4d10..ccd8e3c020 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EndpointTraitBindingGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/EndpointTraitBindingGenerator.kt @@ -10,7 +10,6 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.traits.EndpointTrait import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate @@ -25,7 +24,7 @@ fun EndpointTrait.prefixFormatString(): String { return this.hostPrefix.rustFormatString("", "") } -fun RuntimeConfig.smithyHttp() = CargoDependency.SmithyHttp(this).asType() +fun RuntimeConfig.smithyHttp() = CargoDependency.smithyHttp(this).toType() class EndpointTraitBindings( model: Model, diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/PaginatorGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/PaginatorGenerator.kt index ec77e596e5..262afbd616 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/PaginatorGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/PaginatorGenerator.kt @@ -18,7 +18,6 @@ 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.Visibility import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.render import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate @@ -110,13 +109,13 @@ class PaginatorGenerator private constructor( "Builder" to operation.inputShape(model).builderSymbol(symbolProvider), // SDK Types - "SdkError" to CargoDependency.SmithyHttp(runtimeConfig).asType() + "SdkError" to CargoDependency.smithyHttp(runtimeConfig).toType() .copy(name = "result::SdkError"), - "client" to CargoDependency.SmithyClient(runtimeConfig).asType(), - "fn_stream" to CargoDependency.SmithyAsync(runtimeConfig).asType().member("future::fn_stream"), + "client" to CargoDependency.smithyClient(runtimeConfig).toType(), + "fn_stream" to CargoDependency.smithyAsync(runtimeConfig).toType().member("future::fn_stream"), // External Types - "Stream" to CargoDependency.TokioStream.asType().member("Stream"), + "Stream" to CargoDependency.TokioStream.toType().member("Stream"), ) 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 f796595725..1b1a987254 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 @@ -11,7 +11,6 @@ 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.asType import software.amazon.smithy.rust.codegen.core.rustlang.docs import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate @@ -31,8 +30,8 @@ class CustomizableOperationGenerator( const val CUSTOMIZE_MODULE = "crate::operation::customize" } - private val smithyHttp = CargoDependency.SmithyHttp(runtimeConfig).asType() - private val smithyTypes = CargoDependency.SmithyTypes(runtimeConfig).asType() + private val smithyHttp = CargoDependency.smithyHttp(runtimeConfig).toType() + private val smithyTypes = CargoDependency.smithyTypes(runtimeConfig).toType() fun render(crate: RustCrate) { crate.withModule(RustModule.operation(Visibility.PUBLIC)) { @@ -68,7 +67,7 @@ class CustomizableOperationGenerator( // SDK Types "http_result" to smithyHttp.member("result"), "http_body" to smithyHttp.member("body"), - "HttpRequest" to CargoDependency.Http.asType().member("Request"), + "HttpRequest" to CargoDependency.Http.toType().member("Request"), "handle_generics_decl" to handleGenerics.declaration(), "handle_generics_bounds" to handleGenerics.bounds(), "operation_generics_decl" to operationGenerics.declaration(), @@ -143,8 +142,8 @@ class CustomizableOperationGenerator( } private fun renderCustomizableOperationSend(writer: RustWriter) { - val smithyHttp = CargoDependency.SmithyHttp(runtimeConfig).asType() - val smithyClient = CargoDependency.SmithyClient(runtimeConfig).asType() + val smithyHttp = CargoDependency.smithyHttp(runtimeConfig).toType() + val smithyClient = CargoDependency.smithyClient(runtimeConfig).toType() val operationGenerics = RustGenerics(GenericTypeArg("O"), GenericTypeArg("Retry")) val handleGenerics = generics.toRustGenerics() diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientDecorator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientDecorator.kt index 8e8cf8f8b2..1495c68ce9 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientDecorator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientDecorator.kt @@ -13,7 +13,6 @@ import software.amazon.smithy.rust.codegen.client.smithy.generators.protocol.Cli import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.Feature import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType 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 @@ -82,8 +81,8 @@ abstract class FluentClientCustomization : NamedSectionGenerator writable { 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 81c3964cec..b79537dd01 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 @@ -23,7 +23,6 @@ import software.amazon.smithy.rust.codegen.core.rustlang.RustType import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.asArgumentType import software.amazon.smithy.rust.codegen.core.rustlang.asOptional -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.deprecatedShape import software.amazon.smithy.rust.codegen.core.rustlang.docLink import software.amazon.smithy.rust.codegen.core.rustlang.docs @@ -58,12 +57,12 @@ class FluentClientGenerator( private val generics: FluentClientGenerics = FlexibleClientGenerics( connectorDefault = null, middlewareDefault = null, - retryDefault = CargoDependency.SmithyClient(codegenContext.runtimeConfig).asType() + retryDefault = CargoDependency.smithyClient(codegenContext.runtimeConfig).toType() .member("retry::Standard"), - client = CargoDependency.SmithyClient(codegenContext.runtimeConfig).asType(), + client = CargoDependency.smithyClient(codegenContext.runtimeConfig).toType(), ), private val customizations: List = emptyList(), - private val retryClassifier: RuntimeType = CargoDependency.SmithyHttp(codegenContext.runtimeConfig).asType() + private val retryClassifier: RuntimeType = CargoDependency.smithyHttp(codegenContext.runtimeConfig).toType() .member("retry::DefaultResponseRetryClassifier"), ) { companion object { @@ -81,7 +80,7 @@ class FluentClientGenerator( TopDownIndex.of(codegenContext.model).getContainedOperations(serviceShape).sortedBy { it.id } private val symbolProvider = codegenContext.symbolProvider private val model = codegenContext.model - private val clientDep = CargoDependency.SmithyClient(codegenContext.runtimeConfig) + private val clientDep = CargoDependency.smithyClient(codegenContext.runtimeConfig) private val runtimeConfig = codegenContext.runtimeConfig private val core = FluentClientCore(model) @@ -146,7 +145,7 @@ class FluentClientGenerator( """, "generics_decl" to generics.decl, "smithy_inst" to generics.smithyInst, - "client" to clientDep.asType(), + "client" to clientDep.toType(), "client_docs" to writable { customizations.forEach { @@ -160,7 +159,7 @@ class FluentClientGenerator( ) writer.rustBlockTemplate( "impl${generics.inst} Client${generics.inst} #{bounds:W}", - "client" to clientDep.asType(), + "client" to clientDep.toType(), "bounds" to generics.bounds, ) { operations.forEach { operation -> @@ -255,14 +254,14 @@ class FluentClientGenerator( } """, "Inner" to input.builderSymbol(symbolProvider), - "client" to clientDep.asType(), + "client" to clientDep.toType(), "generics" to generics.decl, "operation" to operationSymbol, ) rustBlockTemplate( "impl${generics.inst} ${operationSymbol.name}${generics.inst} #{bounds:W}", - "client" to clientDep.asType(), + "client" to clientDep.toType(), "bounds" to generics.bounds, ) { val outputType = symbolProvider.toSymbol(operation.outputShape(model)) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/EventStreamSigningConfig.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/EventStreamSigningConfig.kt index 6651503429..6e6e167a5a 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/EventStreamSigningConfig.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/EventStreamSigningConfig.kt @@ -18,12 +18,12 @@ open class EventStreamSigningConfig( private val codegenScope = arrayOf( "SharedPropertyBag" to RuntimeType( "SharedPropertyBag", - CargoDependency.SmithyHttp(runtimeConfig), + CargoDependency.smithyHttp(runtimeConfig), "aws_smithy_http::property_bag", ), "SignMessage" to RuntimeType( "SignMessage", - CargoDependency.SmithyEventStream(runtimeConfig), + CargoDependency.smithyEventStream(runtimeConfig), "aws_smithy_eventstream::frame", ), ) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt index 50bec8cd21..830308060f 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt @@ -27,7 +27,6 @@ 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.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.escape import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock @@ -68,8 +67,8 @@ class ProtocolTestGenerator( private val instantiator = clientInstantiator(codegenContext) private val codegenScope = arrayOf( - "SmithyHttp" to CargoDependency.SmithyHttp(codegenContext.runtimeConfig).asType(), - "AssertEq" to CargoDependency.PrettyAssertions.asType().member("assert_eq!"), + "SmithyHttp" to CargoDependency.smithyHttp(codegenContext.runtimeConfig).toType(), + "AssertEq" to CargoDependency.PrettyAssertions.toType().member("assert_eq!"), ) sealed class TestCase { @@ -282,7 +281,7 @@ class ProtocolTestGenerator( """, "op" to operationSymbol, "bytes" to RuntimeType.Bytes, - "parse_http_response" to CargoDependency.SmithyHttp(codegenContext.runtimeConfig).asType() + "parse_http_response" to CargoDependency.smithyHttp(codegenContext.runtimeConfig).toType() .member("response::ParseHttpResponse"), ) if (expectedShape.hasTrait()) { diff --git a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/HttpVersionListGeneratorTest.kt b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/HttpVersionListGeneratorTest.kt index ae0663290e..5953da8a4f 100644 --- a/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/HttpVersionListGeneratorTest.kt +++ b/codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/customizations/HttpVersionListGeneratorTest.kt @@ -217,22 +217,22 @@ class FakeSigningConfig( private val codegenScope = arrayOf( "SharedPropertyBag" to RuntimeType( "SharedPropertyBag", - CargoDependency.SmithyHttp(runtimeConfig), + CargoDependency.smithyHttp(runtimeConfig), "aws_smithy_http::property_bag", ), "SignMessageError" to RuntimeType( "SignMessageError", - CargoDependency.SmithyEventStream(runtimeConfig), + CargoDependency.smithyEventStream(runtimeConfig), "aws_smithy_eventstream::frame", ), "SignMessage" to RuntimeType( "SignMessage", - CargoDependency.SmithyEventStream(runtimeConfig), + CargoDependency.smithyEventStream(runtimeConfig), "aws_smithy_eventstream::frame", ), "Message" to RuntimeType( "Message", - CargoDependency.SmithyEventStream(runtimeConfig), + CargoDependency.smithyEventStream(runtimeConfig), "aws_smithy_eventstream::frame", ), ) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/CargoDependency.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/CargoDependency.kt index 970c1a63ed..0dddd335d3 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/CargoDependency.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/CargoDependency.kt @@ -45,12 +45,12 @@ sealed class RustDependency(open val name: String) : SymbolDependencyContainer { * A dependency on a snippet of code * * InlineDependency should not be instantiated directly, rather, it should be constructed with - * [software.amazon.smithy.rust.codegen.smithy.RuntimeType.forInlineFun] + * [software.amazon.smithy.rust.codegen.core.smithy.RuntimeType.forInlineFun] * * InlineDependencies are created as private modules within the main crate. This is useful for any code that * doesn't need to exist in a shared crate, but must still be generated exactly once during codegen. * - * CodegenVisitor deduplicates inline dependencies by (module, name) during code generation. + * CodegenVisitor de-duplicates inline dependencies by (module, name) during code generation. */ class InlineDependency( name: String, @@ -96,10 +96,10 @@ class InlineDependency( forRustFile(name, "inlineable", *additionalDependencies) fun eventStream(runtimeConfig: RuntimeConfig) = - forRustFile("event_stream", CargoDependency.SmithyEventStream(runtimeConfig)) + forRustFile("event_stream", CargoDependency.smithyEventStream(runtimeConfig)) fun jsonErrors(runtimeConfig: RuntimeConfig) = - forRustFile("json_errors", CargoDependency.Http, CargoDependency.SmithyTypes(runtimeConfig)) + forRustFile("json_errors", CargoDependency.Http, CargoDependency.smithyTypes(runtimeConfig)) fun idempotencyToken() = forRustFile("idempotency_token", CargoDependency.FastRand) @@ -118,8 +118,6 @@ class InlineDependency( } } -fun CargoDependency.asType() = RuntimeType(null, dependency = this, namespace = rustName) - data class Feature(val name: String, val default: Boolean, val deps: List) /** @@ -135,8 +133,6 @@ data class CargoDependency( ) : RustDependency(name) { val key: Triple get() = Triple(name, location, scope) - fun canMergeWith(other: CargoDependency): Boolean = key == other.key - fun withFeature(feature: String): CargoDependency { return copy(features = features.toMutableSet().apply { add(feature) }) } @@ -146,8 +142,6 @@ data class CargoDependency( is Local -> "local" } - fun rustName(name: String): RuntimeType = RuntimeType(name, this, this.rustName) - fun toMap(): Map { val attribs = mutableMapOf() with(location) { @@ -192,37 +186,61 @@ data class CargoDependency( return "$name = { ${attribs.joinToString(",")} }" } + fun toType(): RuntimeType { + return RuntimeType(null, this, rustName) + } + companion object { val Bytes: CargoDependency = CargoDependency("bytes", CratesIo("1.0.0")) val BytesUtils: CargoDependency = CargoDependency("bytes-utils", CratesIo("0.1.0")) val FastRand: CargoDependency = CargoDependency("fastrand", CratesIo("1.0.0")) val Hex: CargoDependency = CargoDependency("hex", CratesIo("0.4.3")) - val HttpBody: CargoDependency = CargoDependency("http-body", CratesIo("0.4.4")) val Http: CargoDependency = CargoDependency("http", CratesIo("0.2.0")) + val HttpBody: CargoDependency = CargoDependency("http-body", CratesIo("0.4.4")) val Hyper: CargoDependency = CargoDependency("hyper", CratesIo("0.14.12")) val HyperWithStream: CargoDependency = Hyper.withFeature("stream") val LazyStatic: CargoDependency = CargoDependency("lazy_static", CratesIo("1.4.0")) val Md5: CargoDependency = CargoDependency("md-5", CratesIo("0.10.0"), rustName = "md5") val PercentEncoding: CargoDependency = CargoDependency("percent-encoding", CratesIo("2.0.0")) - val PrettyAssertions: CargoDependency = CargoDependency("pretty_assertions", CratesIo("1.0.0"), scope = DependencyScope.Dev) val Regex: CargoDependency = CargoDependency("regex", CratesIo("1.5.5")) val Ring: CargoDependency = CargoDependency("ring", CratesIo("0.16.0")) - val TempFile: CargoDependency = CargoDependency("tempfile", CratesIo("3.2.0"), scope = DependencyScope.Dev) val TokioStream: CargoDependency = CargoDependency("tokio-stream", CratesIo("0.1.7")) val Tower: CargoDependency = CargoDependency("tower", CratesIo("0.4")) val Tracing: CargoDependency = CargoDependency("tracing", CratesIo("0.1")) - fun SmithyTypes(runtimeConfig: RuntimeConfig) = runtimeConfig.runtimeCrate("types") - fun SmithyClient(runtimeConfig: RuntimeConfig) = runtimeConfig.runtimeCrate("client") - fun SmithyChecksums(runtimeConfig: RuntimeConfig) = runtimeConfig.runtimeCrate("checksums") - fun SmithyAsync(runtimeConfig: RuntimeConfig) = runtimeConfig.runtimeCrate("async") - fun SmithyEventStream(runtimeConfig: RuntimeConfig) = runtimeConfig.runtimeCrate("eventstream") - fun SmithyHttp(runtimeConfig: RuntimeConfig) = runtimeConfig.runtimeCrate("http") - fun SmithyHttpTower(runtimeConfig: RuntimeConfig) = runtimeConfig.runtimeCrate("http-tower") - fun SmithyProtocolTestHelpers(runtimeConfig: RuntimeConfig) = - runtimeConfig.runtimeCrate("protocol-test", scope = DependencyScope.Dev) + // Test-only dependencies + val AsyncStd: CargoDependency = CargoDependency("async-std", CratesIo("1.12.0"), DependencyScope.Dev) + val AsyncStream: CargoDependency = CargoDependency("async-stream", CratesIo("0.3.0"), DependencyScope.Dev) + val Criterion: CargoDependency = CargoDependency("criterion", CratesIo("0.4.0"), DependencyScope.Dev) + val FuturesCore: CargoDependency = CargoDependency("futures-core", CratesIo("0.3.0"), DependencyScope.Dev) + val FuturesUtil: CargoDependency = CargoDependency("futures-util", CratesIo("0.3.0"), DependencyScope.Dev) + val Hound: CargoDependency = CargoDependency("hound", CratesIo("3.4.0"), DependencyScope.Dev) + val PrettyAssertions: CargoDependency = + CargoDependency("pretty_assertions", CratesIo("1.0.0"), DependencyScope.Dev) + val SerdeJson: CargoDependency = CargoDependency("serde_json", CratesIo("1.0.0"), DependencyScope.Dev) + val Smol: CargoDependency = CargoDependency("smol", CratesIo("1.2.0"), DependencyScope.Dev) + val TempFile: CargoDependency = CargoDependency("tempfile", CratesIo("3.2.0"), DependencyScope.Dev) + val Tokio: CargoDependency = + CargoDependency("tokio", CratesIo("1.8.4"), DependencyScope.Dev, features = setOf("macros", "test-util")) + val TracingSubscriber: CargoDependency = CargoDependency( + "tracing-subscriber", + CratesIo("0.3.15"), + DependencyScope.Dev, + features = setOf("env-filter"), + ) + + fun smithyAsync(runtimeConfig: RuntimeConfig) = runtimeConfig.runtimeCrate("async") + fun smithyChecksums(runtimeConfig: RuntimeConfig) = runtimeConfig.runtimeCrate("checksums") + fun smithyClient(runtimeConfig: RuntimeConfig) = runtimeConfig.runtimeCrate("client") + fun smithyEventStream(runtimeConfig: RuntimeConfig) = runtimeConfig.runtimeCrate("eventstream") + fun smithyHttp(runtimeConfig: RuntimeConfig) = runtimeConfig.runtimeCrate("http") + fun smithyHttpTower(runtimeConfig: RuntimeConfig) = runtimeConfig.runtimeCrate("http-tower") fun smithyJson(runtimeConfig: RuntimeConfig): CargoDependency = runtimeConfig.runtimeCrate("json") + fun smithyProtocolTestHelpers(runtimeConfig: RuntimeConfig) = + runtimeConfig.runtimeCrate("protocol-test", scope = DependencyScope.Dev) + fun smithyQuery(runtimeConfig: RuntimeConfig): CargoDependency = runtimeConfig.runtimeCrate("query") + fun smithyTypes(runtimeConfig: RuntimeConfig) = runtimeConfig.runtimeCrate("types") fun smithyXml(runtimeConfig: RuntimeConfig): CargoDependency = runtimeConfig.runtimeCrate("xml") } } diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt index 4fc233df32..baabdc7b07 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt @@ -22,7 +22,6 @@ 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.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rustInlineTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.core.util.orNull @@ -177,13 +176,13 @@ data class RuntimeType(val name: String?, val dependency: RustDependency?, val n companion object { fun errorKind(runtimeConfig: RuntimeConfig) = RuntimeType( "ErrorKind", - dependency = CargoDependency.SmithyTypes(runtimeConfig), + dependency = CargoDependency.smithyTypes(runtimeConfig), namespace = "${runtimeConfig.crateSrcPrefix}_types::retry", ) fun provideErrorKind(runtimeConfig: RuntimeConfig) = RuntimeType( "ProvideErrorKind", - dependency = CargoDependency.SmithyTypes(runtimeConfig), + dependency = CargoDependency.smithyTypes(runtimeConfig), namespace = "${runtimeConfig.crateSrcPrefix}_types::retry", ) @@ -205,37 +204,41 @@ data class RuntimeType(val name: String?, val dependency: RustDependency?, val n val String = RuntimeType("String", dependency = null, namespace = "std::string") fun DateTime(runtimeConfig: RuntimeConfig) = - RuntimeType("DateTime", CargoDependency.SmithyTypes(runtimeConfig), "${runtimeConfig.crateSrcPrefix}_types") + RuntimeType("DateTime", CargoDependency.smithyTypes(runtimeConfig), "${runtimeConfig.crateSrcPrefix}_types") fun GenericError(runtimeConfig: RuntimeConfig) = - RuntimeType("Error", CargoDependency.SmithyTypes(runtimeConfig), "${runtimeConfig.crateSrcPrefix}_types") + RuntimeType("Error", CargoDependency.smithyTypes(runtimeConfig), "${runtimeConfig.crateSrcPrefix}_types") fun Blob(runtimeConfig: RuntimeConfig) = - RuntimeType("Blob", CargoDependency.SmithyTypes(runtimeConfig), "${runtimeConfig.crateSrcPrefix}_types") + RuntimeType("Blob", CargoDependency.smithyTypes(runtimeConfig), "${runtimeConfig.crateSrcPrefix}_types") fun ByteStream(runtimeConfig: RuntimeConfig) = - RuntimeType("ByteStream", CargoDependency.SmithyHttp(runtimeConfig), "${runtimeConfig.crateSrcPrefix}_http::byte_stream") + RuntimeType( + "ByteStream", + CargoDependency.smithyHttp(runtimeConfig), + "${runtimeConfig.crateSrcPrefix}_http::byte_stream", + ) fun Document(runtimeConfig: RuntimeConfig): RuntimeType = - RuntimeType("Document", CargoDependency.SmithyTypes(runtimeConfig), "${runtimeConfig.crateSrcPrefix}_types") + RuntimeType("Document", CargoDependency.smithyTypes(runtimeConfig), "${runtimeConfig.crateSrcPrefix}_types") fun LabelFormat(runtimeConfig: RuntimeConfig, func: String) = - RuntimeType(func, CargoDependency.SmithyHttp(runtimeConfig), "${runtimeConfig.crateSrcPrefix}_http::label") + RuntimeType(func, CargoDependency.smithyHttp(runtimeConfig), "${runtimeConfig.crateSrcPrefix}_http::label") fun QueryFormat(runtimeConfig: RuntimeConfig, func: String) = - RuntimeType(func, CargoDependency.SmithyHttp(runtimeConfig), "${runtimeConfig.crateSrcPrefix}_http::query") + RuntimeType(func, CargoDependency.smithyHttp(runtimeConfig), "${runtimeConfig.crateSrcPrefix}_http::query") fun Base64Encode(runtimeConfig: RuntimeConfig): RuntimeType = RuntimeType( "encode", - CargoDependency.SmithyTypes(runtimeConfig), + CargoDependency.smithyTypes(runtimeConfig), "${runtimeConfig.crateSrcPrefix}_types::base64", ) fun Base64Decode(runtimeConfig: RuntimeConfig): RuntimeType = RuntimeType( "decode", - CargoDependency.SmithyTypes(runtimeConfig), + CargoDependency.smithyTypes(runtimeConfig), "${runtimeConfig.crateSrcPrefix}_types::base64", ) @@ -248,20 +251,20 @@ data class RuntimeType(val name: String?, val dependency: RustDependency?, val n } return RuntimeType( timestampFormat, - CargoDependency.SmithyTypes(runtimeConfig), + CargoDependency.smithyTypes(runtimeConfig), "${runtimeConfig.crateSrcPrefix}_types::date_time::Format", ) } fun ProtocolTestHelper(runtimeConfig: RuntimeConfig, func: String): RuntimeType = RuntimeType( - func, CargoDependency.SmithyProtocolTestHelpers(runtimeConfig), "aws_smithy_protocol_test", + func, CargoDependency.smithyProtocolTestHelpers(runtimeConfig), "aws_smithy_protocol_test", ) fun ConstrainedTrait() = RuntimeType("Constrained", InlineDependency.constrained(), namespace = "crate::constrained") fun MaybeConstrained() = RuntimeType("MaybeConstrained", InlineDependency.constrained(), namespace = "crate::constrained") - val http = CargoDependency.Http.asType() + val http = CargoDependency.Http.toType() fun Http(path: String): RuntimeType = RuntimeType(name = path, dependency = CargoDependency.Http, namespace = "http") @@ -271,7 +274,7 @@ data class RuntimeType(val name: String?, val dependency: RustDependency?, val n fun eventStreamReceiver(runtimeConfig: RuntimeConfig): RuntimeType = RuntimeType( "Receiver", - dependency = CargoDependency.SmithyHttp(runtimeConfig), + dependency = CargoDependency.smithyHttp(runtimeConfig), "aws_smithy_http::event_stream", ) @@ -283,22 +286,22 @@ data class RuntimeType(val name: String?, val dependency: RustDependency?, val n fun operation(runtimeConfig: RuntimeConfig) = RuntimeType( "Operation", - dependency = CargoDependency.SmithyHttp(runtimeConfig), + dependency = CargoDependency.smithyHttp(runtimeConfig), namespace = "aws_smithy_http::operation", ) fun operationModule(runtimeConfig: RuntimeConfig) = RuntimeType( null, - dependency = CargoDependency.SmithyHttp(runtimeConfig), + dependency = CargoDependency.smithyHttp(runtimeConfig), namespace = "aws_smithy_http::operation", ) fun sdkBody(runtimeConfig: RuntimeConfig): RuntimeType = - RuntimeType("SdkBody", dependency = CargoDependency.SmithyHttp(runtimeConfig), "aws_smithy_http::body") + RuntimeType("SdkBody", dependency = CargoDependency.smithyHttp(runtimeConfig), "aws_smithy_http::body") fun parseStrictResponse(runtimeConfig: RuntimeConfig) = RuntimeType( "ParseStrictResponse", - dependency = CargoDependency.SmithyHttp(runtimeConfig), + dependency = CargoDependency.smithyHttp(runtimeConfig), namespace = "aws_smithy_http::response", ) @@ -315,7 +318,7 @@ data class RuntimeType(val name: String?, val dependency: RustDependency?, val n fun parseResponse(runtimeConfig: RuntimeConfig) = RuntimeType( "ParseHttpResponse", - dependency = CargoDependency.SmithyHttp(runtimeConfig), + dependency = CargoDependency.smithyHttp(runtimeConfig), namespace = "aws_smithy_http::response", ) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/Instantiator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/Instantiator.kt index 7973af7603..ece470137d 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/Instantiator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/Instantiator.kt @@ -35,7 +35,6 @@ import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.RustType import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.conditionalBlock import software.amazon.smithy.rust.codegen.core.rustlang.escape import software.amazon.smithy.rust.codegen.core.rustlang.rust @@ -138,7 +137,7 @@ open class Instantiator( writer.rust( """<#T as #T>::parse_smithy_primitive(${data.value.dq()}).expect("invalid string for number")""", numberSymbol, - CargoDependency.SmithyTypes(runtimeConfig).asType().member("primitive::Parse"), + CargoDependency.smithyTypes(runtimeConfig).toType().member("primitive::Parse"), ) } @@ -147,7 +146,7 @@ open class Instantiator( is BooleanShape -> writer.rust(data.asBooleanNode().get().toString()) is DocumentShape -> writer.rustBlock("") { - val smithyJson = CargoDependency.smithyJson(runtimeConfig).asType() + val smithyJson = CargoDependency.smithyJson(runtimeConfig).toType() rustTemplate( """ let json_bytes = br##"${Node.prettyPrintJson(data)}"##; diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/CombinedErrorGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/CombinedErrorGenerator.kt index c8d36bc0cc..485878f033 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/CombinedErrorGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/CombinedErrorGenerator.kt @@ -19,7 +19,6 @@ 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.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.deprecatedShape import software.amazon.smithy.rust.codegen.core.rustlang.docs import software.amazon.smithy.rust.codegen.core.rustlang.documentShape @@ -127,7 +126,8 @@ class CombinedErrorGenerator( ) { private val runtimeConfig = symbolProvider.config().runtimeConfig private val genericError = RuntimeType.GenericError(symbolProvider.config().runtimeConfig) - private val createUnhandledError = CargoDependency.SmithyHttp(runtimeConfig).asType().member("result::CreateUnhandledError") + private val createUnhandledError = + CargoDependency.smithyHttp(runtimeConfig).toType().member("result::CreateUnhandledError") fun render(writer: RustWriter) { val errorSymbol = RuntimeType("${operationSymbol.name}Error", null, "crate::error") diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/TopLevelErrorGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/TopLevelErrorGenerator.kt index 6511ba1bef..e43c8a444e 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/TopLevelErrorGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/error/TopLevelErrorGenerator.kt @@ -14,7 +14,6 @@ import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata 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.asType import software.amazon.smithy.rust.codegen.core.rustlang.deprecatedShape import software.amazon.smithy.rust.codegen.core.rustlang.docs import software.amazon.smithy.rust.codegen.core.rustlang.documentShape @@ -52,7 +51,7 @@ class TopLevelErrorGenerator(private val codegenContext: CodegenContext, private .map { codegenContext.model.expectShape(it, StructureShape::class.java) } .sortedBy { it.id.getName(codegenContext.serviceShape) } - private val sdkError = CargoDependency.SmithyHttp(codegenContext.runtimeConfig).asType().member("result::SdkError") + private val sdkError = CargoDependency.smithyHttp(codegenContext.runtimeConfig).toType().member("result::SdkError") fun render(crate: RustCrate) { crate.withModule(RustModule.private("error_meta")) { renderDefinition() diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt index 54b38a54f1..219784eff3 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt @@ -30,7 +30,6 @@ 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.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.asOptional -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.autoDeref import software.amazon.smithy.rust.codegen.core.rustlang.render import software.amazon.smithy.rust.codegen.core.rustlang.rust @@ -119,7 +118,7 @@ class HttpBindingGenerator( private val model = codegenContext.model private val service = codegenContext.serviceShape private val index = HttpBindingIndex.of(model) - private val headerUtil = CargoDependency.SmithyHttp(runtimeConfig).asType().member("header") + private val headerUtil = CargoDependency.smithyHttp(runtimeConfig).toType().member("header") private val defaultTimestampFormat = TimestampFormatTrait.Format.EPOCH_SECONDS private val dateTime = RuntimeType.DateTime(runtimeConfig).toSymbol().rustType() private val httpSerdeModule = RustModule.private("http_serde") @@ -524,7 +523,7 @@ class HttpBindingGenerator( listForEach(targetShape, field) { innerField, targetId -> val innerMemberType = model.expectShape(targetId) if (innerMemberType.isPrimitive()) { - val encoder = CargoDependency.SmithyTypes(runtimeConfig).asType().member("primitive::Encoder") + val encoder = CargoDependency.smithyTypes(runtimeConfig).toType().member("primitive::Encoder") rust("let mut encoder = #T::from(${autoDeref(innerField)});", encoder) } val formatted = headerFmtFun( diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/RequestBindingGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/RequestBindingGenerator.kt index caf3c07172..6356861a6c 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/RequestBindingGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/RequestBindingGenerator.kt @@ -18,7 +18,6 @@ import software.amazon.smithy.model.traits.HttpTrait import software.amazon.smithy.rust.codegen.core.rustlang.Attribute import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.autoDeref import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock @@ -72,7 +71,7 @@ class RequestBindingGenerator( private val httpBindingGenerator = HttpBindingGenerator(protocol, codegenContext, codegenContext.symbolProvider, operationShape, ::builderSymbol) private val index = HttpBindingIndex.of(model) - private val Encoder = CargoDependency.SmithyTypes(runtimeConfig).asType().member("primitive::Encoder") + private val Encoder = CargoDependency.smithyTypes(runtimeConfig).toType().member("primitive::Encoder") private val codegenScope = arrayOf( "BuildError" to runtimeConfig.operationBuildError(), diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/RestRequestSpecGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/RestRequestSpecGenerator.kt index df401f7636..2a93d75ddf 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/RestRequestSpecGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/RestRequestSpecGenerator.kt @@ -8,7 +8,6 @@ package software.amazon.smithy.rust.codegen.core.smithy.generators.http import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.withBlock import software.amazon.smithy.rust.codegen.core.rustlang.writable @@ -87,7 +86,7 @@ class RestRequestSpecGenerator( *extraCodegenScope, "PathSegmentsVec" to pathSegmentsVec, "QuerySegmentsVec" to querySegmentsVec, - "Method" to CargoDependency.Http.asType().member("Method"), + "Method" to CargoDependency.Http.toType().member("Method"), ) } } diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/MakeOperationGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/MakeOperationGenerator.kt index 94d4cd28f1..47747babd1 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/MakeOperationGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/MakeOperationGenerator.kt @@ -11,7 +11,6 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.core.rustlang.Attribute import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.docs import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate @@ -49,8 +48,8 @@ open class MakeOperationGenerator( protected val runtimeConfig = codegenContext.runtimeConfig protected val symbolProvider = codegenContext.symbolProvider protected val httpBindingResolver = protocol.httpBindingResolver - private val defaultClassifier = CargoDependency.SmithyHttp(runtimeConfig) - .asType().member("retry::DefaultResponseRetryClassifier") + private val defaultClassifier = CargoDependency.smithyHttp(runtimeConfig) + .toType().member("retry::DefaultResponseRetryClassifier") private val sdkId = codegenContext.serviceShape.getTrait()?.sdkId?.lowercase()?.replace(" ", "") @@ -58,7 +57,7 @@ open class MakeOperationGenerator( private val codegenScope = arrayOf( "config" to RuntimeType.Config, - "header_util" to CargoDependency.SmithyHttp(runtimeConfig).asType().member("header"), + "header_util" to CargoDependency.smithyHttp(runtimeConfig).toType().member("header"), "http" to RuntimeType.http, "HttpRequestBuilder" to RuntimeType.HttpRequestBuilder, "OpBuildError" to codegenContext.runtimeConfig.operationBuildError(), diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/AwsJson.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/AwsJson.kt index 814aa64e68..c5c13db5f1 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/AwsJson.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/AwsJson.kt @@ -14,7 +14,6 @@ import software.amazon.smithy.model.traits.HttpTrait import software.amazon.smithy.model.traits.TimestampFormatTrait 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.asType import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext @@ -114,7 +113,8 @@ open class AwsJson( "Bytes" to RuntimeType.Bytes, "Error" to RuntimeType.GenericError(runtimeConfig), "HeaderMap" to RuntimeType.http.member("HeaderMap"), - "JsonError" to CargoDependency.smithyJson(runtimeConfig).asType().member("deserialize::error::DeserializeError"), + "JsonError" to CargoDependency.smithyJson(runtimeConfig).toType() + .member("deserialize::error::DeserializeError"), "Response" to RuntimeType.http.member("Response"), "json_errors" to RuntimeType.jsonErrors(runtimeConfig), ) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/AwsQuery.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/AwsQuery.kt index 6b6d1d46c5..60985edd5b 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/AwsQuery.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/AwsQuery.kt @@ -16,7 +16,6 @@ import software.amazon.smithy.model.traits.HttpTrait import software.amazon.smithy.model.traits.TimestampFormatTrait 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.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext @@ -50,7 +49,7 @@ class AwsQueryProtocol(private val codegenContext: CodegenContext) : Protocol { "Error" to RuntimeType.GenericError(runtimeConfig), "HeaderMap" to RuntimeType.http.member("HeaderMap"), "Response" to RuntimeType.http.member("Response"), - "XmlDecodeError" to CargoDependency.smithyXml(runtimeConfig).asType().member("decode::XmlDecodeError"), + "XmlDecodeError" to CargoDependency.smithyXml(runtimeConfig).toType().member("decode::XmlDecodeError"), ) private val xmlDeserModule = RustModule.private("xml_deser") diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/Ec2Query.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/Ec2Query.kt index 0786e76c91..2ab550048f 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/Ec2Query.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/Ec2Query.kt @@ -13,7 +13,6 @@ import software.amazon.smithy.model.traits.HttpTrait import software.amazon.smithy.model.traits.TimestampFormatTrait 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.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext @@ -32,7 +31,7 @@ class Ec2QueryProtocol(private val codegenContext: CodegenContext) : Protocol { "Error" to RuntimeType.GenericError(runtimeConfig), "HeaderMap" to RuntimeType.http.member("HeaderMap"), "Response" to RuntimeType.http.member("Response"), - "XmlDecodeError" to CargoDependency.smithyXml(runtimeConfig).asType().member("decode::XmlDecodeError"), + "XmlDecodeError" to CargoDependency.smithyXml(runtimeConfig).toType().member("decode::XmlDecodeError"), ) private val xmlDeserModule = RustModule.private("xml_deser") diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt index 5c5cf72f54..4c6d614139 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/HttpBoundProtocolPayloadGenerator.kt @@ -17,7 +17,6 @@ import software.amazon.smithy.model.traits.EnumTrait 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.RustWriter -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate @@ -58,12 +57,12 @@ class HttpBoundProtocolPayloadGenerator( private val operationSerModule = RustModule.private("operation_ser") - private val smithyEventStream = CargoDependency.SmithyEventStream(runtimeConfig) + private val smithyEventStream = CargoDependency.smithyEventStream(runtimeConfig) private val codegenScope = arrayOf( - "hyper" to CargoDependency.HyperWithStream.asType(), + "hyper" to CargoDependency.HyperWithStream.toType(), "SdkBody" to RuntimeType.sdkBody(runtimeConfig), "BuildError" to runtimeConfig.operationBuildError(), - "SmithyHttp" to CargoDependency.SmithyHttp(runtimeConfig).asType(), + "SmithyHttp" to CargoDependency.smithyHttp(runtimeConfig).toType(), "NoOpSigner" to RuntimeType("NoOpSigner", smithyEventStream, "aws_smithy_eventstream::frame"), ) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/RestJson.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/RestJson.kt index 0a7234f548..6e8cf0f13a 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/RestJson.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/RestJson.kt @@ -17,7 +17,6 @@ import software.amazon.smithy.model.traits.StreamingTrait import software.amazon.smithy.model.traits.TimestampFormatTrait 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.asType import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType @@ -69,7 +68,8 @@ open class RestJson(val codegenContext: CodegenContext) : Protocol { "Bytes" to RuntimeType.Bytes, "Error" to RuntimeType.GenericError(runtimeConfig), "HeaderMap" to RuntimeType.http.member("HeaderMap"), - "JsonError" to CargoDependency.smithyJson(runtimeConfig).asType().member("deserialize::error::DeserializeError"), + "JsonError" to CargoDependency.smithyJson(runtimeConfig).toType() + .member("deserialize::error::DeserializeError"), "Response" to RuntimeType.http.member("Response"), "json_errors" to RuntimeType.jsonErrors(runtimeConfig), ) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/RestXml.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/RestXml.kt index 153088e53e..a87f607670 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/RestXml.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/RestXml.kt @@ -12,7 +12,6 @@ import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.traits.TimestampFormatTrait 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.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext @@ -32,7 +31,7 @@ open class RestXml(val codegenContext: CodegenContext) : Protocol { "Error" to RuntimeType.GenericError(runtimeConfig), "HeaderMap" to RuntimeType.http.member("HeaderMap"), "Response" to RuntimeType.http.member("Response"), - "XmlDecodeError" to CargoDependency.smithyXml(runtimeConfig).asType().member("decode::XmlDecodeError"), + "XmlDecodeError" to CargoDependency.smithyXml(runtimeConfig).toType().member("decode::XmlDecodeError"), ) private val xmlDeserModule = RustModule.private("xml_deser") diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/EventStreamUnmarshallerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/EventStreamUnmarshallerGenerator.kt index 056be65fc4..da4c4d396d 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/EventStreamUnmarshallerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/EventStreamUnmarshallerGenerator.kt @@ -24,7 +24,6 @@ import software.amazon.smithy.model.traits.EventPayloadTrait 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.RustWriter -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.conditionalBlock import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock @@ -59,7 +58,7 @@ class EventStreamUnmarshallerGenerator( private val codegenTarget = codegenContext.target private val runtimeConfig = codegenContext.runtimeConfig private val unionSymbol = symbolProvider.toSymbol(unionShape) - private val smithyEventStream = CargoDependency.SmithyEventStream(runtimeConfig) + private val smithyEventStream = CargoDependency.smithyEventStream(runtimeConfig) private val errorSymbol = if (codegenTarget == CodegenTarget.SERVER && unionShape.eventStreamErrors().isEmpty()) { RuntimeType("MessageStreamError", smithyEventStream, "aws_smithy_http::event_stream").toSymbol() } else { @@ -67,15 +66,15 @@ class EventStreamUnmarshallerGenerator( } private val eventStreamSerdeModule = RustModule.private("event_stream_serde") private val codegenScope = arrayOf( - "Blob" to RuntimeType("Blob", CargoDependency.SmithyTypes(runtimeConfig), "aws_smithy_types"), + "Blob" to RuntimeType("Blob", CargoDependency.smithyTypes(runtimeConfig), "aws_smithy_types"), "Error" to RuntimeType("Error", smithyEventStream, "aws_smithy_eventstream::error"), "expect_fns" to RuntimeType("smithy", smithyEventStream, "aws_smithy_eventstream"), "Header" to RuntimeType("Header", smithyEventStream, "aws_smithy_eventstream::frame"), "HeaderValue" to RuntimeType("HeaderValue", smithyEventStream, "aws_smithy_eventstream::frame"), "Message" to RuntimeType("Message", smithyEventStream, "aws_smithy_eventstream::frame"), "OpError" to errorSymbol, - "SmithyError" to RuntimeType("Error", CargoDependency.SmithyTypes(runtimeConfig), "aws_smithy_types"), - "tracing" to CargoDependency.Tracing.asType(), + "SmithyError" to RuntimeType("Error", CargoDependency.smithyTypes(runtimeConfig), "aws_smithy_types"), + "tracing" to CargoDependency.Tracing.toType(), "UnmarshalledMessage" to RuntimeType("UnmarshalledMessage", smithyEventStream, "aws_smithy_eventstream::frame"), "UnmarshallMessage" to RuntimeType("UnmarshallMessage", smithyEventStream, "aws_smithy_eventstream::frame"), ) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt index bafb8fb67e..1d7a099272 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt @@ -28,7 +28,6 @@ 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.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.escape import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock @@ -97,7 +96,7 @@ class JsonParserGenerator( private val symbolProvider = codegenContext.symbolProvider private val runtimeConfig = codegenContext.runtimeConfig private val codegenTarget = codegenContext.target - private val smithyJson = CargoDependency.smithyJson(runtimeConfig).asType() + private val smithyJson = CargoDependency.smithyJson(runtimeConfig).toType() private val jsonDeserModule = RustModule.private("json_deser") private val typeConversionGenerator = TypeConversionGenerator(model, symbolProvider, runtimeConfig) private val codegenScope = arrayOf( diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt index b70cb55efb..5f685fbc29 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/XmlBindingTraitParserGenerator.kt @@ -30,7 +30,6 @@ 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.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.conditionalBlock import software.amazon.smithy.rust.codegen.core.rustlang.escape import software.amazon.smithy.rust.codegen.core.rustlang.rust @@ -97,7 +96,7 @@ class XmlBindingTraitParserGenerator( data class Ctx(val tag: String, val accum: String?) private val symbolProvider = codegenContext.symbolProvider - private val smithyXml = CargoDependency.smithyXml(codegenContext.runtimeConfig).asType() + private val smithyXml = CargoDependency.smithyXml(codegenContext.runtimeConfig).toType() private val xmlDecodeError = smithyXml.member("decode::XmlDecodeError") private val scopedDecoder = smithyXml.member("decode::ScopedDecoder") @@ -111,7 +110,7 @@ class XmlBindingTraitParserGenerator( "next_start_element" to smithyXml.member("decode::next_start_element"), "try_data" to smithyXml.member("decode::try_data"), "ScopedDecoder" to scopedDecoder, - "aws_smithy_types" to CargoDependency.SmithyTypes(runtimeConfig).asType(), + "aws_smithy_types" to CargoDependency.smithyTypes(runtimeConfig).toType(), ) private val model = codegenContext.model private val index = HttpBindingIndex.of(model) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamErrorMarshallerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamErrorMarshallerGenerator.kt index 1f1995c6c8..a8793919ea 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamErrorMarshallerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamErrorMarshallerGenerator.kt @@ -45,7 +45,7 @@ class EventStreamErrorMarshallerGenerator( private val serializerGenerator: StructuredDataSerializerGenerator, payloadContentType: String, ) : EventStreamMarshallerGenerator(model, target, runtimeConfig, symbolProvider, unionShape, serializerGenerator, payloadContentType) { - private val smithyEventStream = CargoDependency.SmithyEventStream(runtimeConfig) + private val smithyEventStream = CargoDependency.smithyEventStream(runtimeConfig) private val operationErrorSymbol = if (target == CodegenTarget.SERVER && unionShape.eventStreamErrors().isEmpty()) { RuntimeType("MessageStreamError", smithyEventStream, "aws_smithy_http::event_stream").toSymbol() } else { diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamMarshallerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamMarshallerGenerator.kt index 062d802c46..3db5060814 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamMarshallerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/EventStreamMarshallerGenerator.kt @@ -53,7 +53,7 @@ open class EventStreamMarshallerGenerator( private val serializerGenerator: StructuredDataSerializerGenerator, private val payloadContentType: String, ) { - private val smithyEventStream = CargoDependency.SmithyEventStream(runtimeConfig) + private val smithyEventStream = CargoDependency.smithyEventStream(runtimeConfig) private val eventStreamSerdeModule = RustModule.private("event_stream_serde") private val codegenScope = arrayOf( "MarshallMessage" to RuntimeType("MarshallMessage", smithyEventStream, "aws_smithy_eventstream::frame"), diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/JsonSerializerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/JsonSerializerGenerator.kt index 4ea25612b6..82be9e7818 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/JsonSerializerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/JsonSerializerGenerator.kt @@ -24,7 +24,6 @@ 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.RustWriter -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate @@ -157,8 +156,8 @@ class JsonSerializerGenerator( private val symbolProvider = codegenContext.symbolProvider private val codegenTarget = codegenContext.target private val runtimeConfig = codegenContext.runtimeConfig - private val smithyTypes = CargoDependency.SmithyTypes(runtimeConfig).asType() - private val smithyJson = CargoDependency.smithyJson(runtimeConfig).asType() + private val smithyTypes = CargoDependency.smithyTypes(runtimeConfig).toType() + private val smithyJson = CargoDependency.smithyJson(runtimeConfig).toType() private val codegenScope = arrayOf( "String" to RuntimeType.String, "Error" to runtimeConfig.serializationError(), diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/QuerySerializerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/QuerySerializerGenerator.kt index 70808148df..9e4eded243 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/QuerySerializerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/QuerySerializerGenerator.kt @@ -25,7 +25,6 @@ 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.RustWriter -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate @@ -93,8 +92,8 @@ abstract class QuerySerializerGenerator(codegenContext: CodegenContext) : Struct private val target = codegenContext.target private val serviceShape = codegenContext.serviceShape private val serializerError = runtimeConfig.serializationError() - private val smithyTypes = CargoDependency.SmithyTypes(runtimeConfig).asType() - private val smithyQuery = CargoDependency.smithyQuery(runtimeConfig).asType() + private val smithyTypes = CargoDependency.smithyTypes(runtimeConfig).toType() + private val smithyQuery = CargoDependency.smithyQuery(runtimeConfig).toType() private val serdeUtil = SerializerUtil(model) private val codegenScope = arrayOf( "String" to RuntimeType.String, diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/XmlBindingTraitSerializerGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/XmlBindingTraitSerializerGenerator.kt index cf8a77a76f..f5aabdc37c 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/XmlBindingTraitSerializerGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/XmlBindingTraitSerializerGenerator.kt @@ -27,7 +27,6 @@ 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.RustWriter -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.autoDeref import software.amazon.smithy.rust.codegen.core.rustlang.render import software.amazon.smithy.rust.codegen.core.rustlang.rust @@ -62,7 +61,7 @@ class XmlBindingTraitSerializerGenerator( private val symbolProvider = codegenContext.symbolProvider private val runtimeConfig = codegenContext.runtimeConfig private val model = codegenContext.model - private val smithyXml = CargoDependency.smithyXml(runtimeConfig).asType() + private val smithyXml = CargoDependency.smithyXml(runtimeConfig).toType() private val codegenTarget = codegenContext.target private val codegenScope = arrayOf( @@ -303,7 +302,7 @@ class XmlBindingTraitSerializerGenerator( is BooleanShape, is NumberShape -> { rust( "#T::from(${autoDeref(input)}).encode()", - CargoDependency.SmithyTypes(runtimeConfig).asType().member("primitive::Encoder"), + CargoDependency.smithyTypes(runtimeConfig).toType().member("primitive::Encoder"), ) } is BlobShape -> rust("#T($input.as_ref()).as_ref()", RuntimeType.Base64Encode(runtimeConfig)) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/testutil/TestHelpers.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/testutil/TestHelpers.kt index f5f08e9076..2e5fb3a0d0 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/testutil/TestHelpers.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/testutil/TestHelpers.kt @@ -16,7 +16,6 @@ import software.amazon.smithy.rust.codegen.core.rustlang.CratesIo import software.amazon.smithy.rust.codegen.core.rustlang.DependencyScope import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWordSymbolProvider import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.smithy.BaseSymbolMetadataProvider import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.CodegenTarget @@ -122,4 +121,4 @@ val TokioWithTestMacros = CargoDependency( scope = DependencyScope.Dev, ) -val TokioTest = Attribute.Custom("tokio::test", listOf(TokioWithTestMacros.asType())) +val TokioTest = Attribute.Custom("tokio::test", listOf(TokioWithTestMacros.toType())) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/util/Map.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/util/Map.kt index a326ee67ff..00c4450a55 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/util/Map.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/util/Map.kt @@ -5,8 +5,6 @@ package software.amazon.smithy.rust.codegen.core.util -import kotlin.collections.Map - /** * Deep merges two maps, with the properties of `other` taking priority over the properties of `this`. */ diff --git a/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriterTest.kt b/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriterTest.kt index a721b9ad66..4c18a23c2e 100644 --- a/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriterTest.kt +++ b/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustWriterTest.kt @@ -155,7 +155,7 @@ class RustWriterTest { sut.rustTemplate( "inner: #{Inner:W}, regular: #{http}", "Inner" to inner, - "http" to CargoDependency.Http.asType().member("foo"), + "http" to CargoDependency.Http.toType().member("foo"), ) sut.toString().shouldContain("inner: hello, regular: http::foo") } diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonApplicationGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonApplicationGenerator.kt index b7ac1793aa..4431b5f0a4 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonApplicationGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonApplicationGenerator.kt @@ -9,7 +9,6 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.traits.DocumentationTrait import software.amazon.smithy.rust.codegen.core.rustlang.RustType import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate @@ -76,18 +75,18 @@ class PythonApplicationGenerator( private val model = codegenContext.model private val codegenScope = arrayOf( - "SmithyPython" to PythonServerCargoDependency.SmithyHttpServerPython(runtimeConfig).asType(), - "SmithyServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).asType(), - "pyo3" to PythonServerCargoDependency.PyO3.asType(), - "pyo3_asyncio" to PythonServerCargoDependency.PyO3Asyncio.asType(), - "tokio" to PythonServerCargoDependency.Tokio.asType(), - "tracing" to PythonServerCargoDependency.Tracing.asType(), - "tower" to PythonServerCargoDependency.Tower.asType(), - "tower_http" to PythonServerCargoDependency.TowerHttp.asType(), - "num_cpus" to PythonServerCargoDependency.NumCpus.asType(), - "hyper" to PythonServerCargoDependency.Hyper.asType(), + "SmithyPython" to PythonServerCargoDependency.SmithyHttpServerPython(runtimeConfig).toType(), + "SmithyServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).toType(), + "pyo3" to PythonServerCargoDependency.PyO3.toType(), + "pyo3_asyncio" to PythonServerCargoDependency.PyO3Asyncio.toType(), + "tokio" to PythonServerCargoDependency.Tokio.toType(), + "tracing" to PythonServerCargoDependency.Tracing.toType(), + "tower" to PythonServerCargoDependency.Tower.toType(), + "tower_http" to PythonServerCargoDependency.TowerHttp.toType(), + "num_cpus" to PythonServerCargoDependency.NumCpus.toType(), + "hyper" to PythonServerCargoDependency.Hyper.toType(), "HashMap" to RustType.HashMap.RuntimeType, - "parking_lot" to PythonServerCargoDependency.ParkingLot.asType(), + "parking_lot" to PythonServerCargoDependency.ParkingLot.toType(), "http" to RuntimeType.http, ) diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerCombinedErrorGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerCombinedErrorGenerator.kt index 53d4713aa0..42d6f07fcf 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerCombinedErrorGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerCombinedErrorGenerator.kt @@ -10,7 +10,6 @@ import software.amazon.smithy.model.knowledge.OperationIndex import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType 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 @@ -53,7 +52,7 @@ class PythonServerCombinedErrorGenerator( } """, - "pyo3" to PythonServerCargoDependency.PyO3.asType(), + "pyo3" to PythonServerCargoDependency.PyO3.toType(), "Error" to operation.errorSymbol(model, symbolProvider, CodegenTarget.SERVER), "From" to RuntimeType.From, "CastPyErrToRustError" to castPyErrToRustError(), diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerEnumGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerEnumGenerator.kt index cad7bad677..c4542c1025 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerEnumGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerEnumGenerator.kt @@ -9,7 +9,6 @@ import software.amazon.smithy.model.shapes.StringShape import software.amazon.smithy.rust.codegen.core.rustlang.Attribute import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate @@ -30,7 +29,7 @@ class PythonServerEnumGenerator( shape: StringShape, ) : ServerEnumGenerator(codegenContext, writer, shape) { - private val pyo3Symbols = listOf(PythonServerCargoDependency.PyO3.asType()) + private val pyo3Symbols = listOf(PythonServerCargoDependency.PyO3.toType()) override fun render() { renderPyClass() diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerModuleGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerModuleGenerator.kt index 6bade55562..a8620e6312 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerModuleGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerModuleGenerator.kt @@ -12,7 +12,6 @@ import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.model.shapes.Shape 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.asType import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.smithy.RustCrate @@ -26,8 +25,8 @@ class PythonServerModuleGenerator( private val serviceShapes: Set, ) { private val codegenScope = arrayOf( - "SmithyPython" to PythonServerCargoDependency.SmithyHttpServerPython(codegenContext.runtimeConfig).asType(), - "pyo3" to PythonServerCargoDependency.PyO3.asType(), + "SmithyPython" to PythonServerCargoDependency.SmithyHttpServerPython(codegenContext.runtimeConfig).toType(), + "pyo3" to PythonServerCargoDependency.PyO3.toType(), ) private val symbolProvider = codegenContext.symbolProvider private val libName = "lib${codegenContext.settings.moduleName.toSnakeCase()}" diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt index c3d1f19146..e7b1aaddb5 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt @@ -8,7 +8,6 @@ package software.amazon.smithy.rust.codegen.server.python.smithy.generators import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType 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 @@ -41,12 +40,12 @@ class PythonServerOperationHandlerGenerator( private val runtimeConfig = codegenContext.runtimeConfig private val codegenScope = arrayOf( - "SmithyPython" to PythonServerCargoDependency.SmithyHttpServerPython(runtimeConfig).asType(), - "SmithyServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).asType(), - "pyo3" to PythonServerCargoDependency.PyO3.asType(), - "pyo3_asyncio" to PythonServerCargoDependency.PyO3Asyncio.asType(), - "tokio" to PythonServerCargoDependency.Tokio.asType(), - "tracing" to PythonServerCargoDependency.Tracing.asType(), + "SmithyPython" to PythonServerCargoDependency.SmithyHttpServerPython(runtimeConfig).toType(), + "SmithyServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).toType(), + "pyo3" to PythonServerCargoDependency.PyO3.toType(), + "pyo3_asyncio" to PythonServerCargoDependency.PyO3Asyncio.toType(), + "tokio" to PythonServerCargoDependency.Tokio.toType(), + "tracing" to PythonServerCargoDependency.Tracing.toType(), ) override fun render(writer: RustWriter) { diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerStructureGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerStructureGenerator.kt index faea82110b..468c1c5313 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerStructureGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerStructureGenerator.kt @@ -13,7 +13,6 @@ import software.amazon.smithy.model.traits.ErrorTrait import software.amazon.smithy.rust.codegen.core.rustlang.Attribute import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.render import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate @@ -36,7 +35,7 @@ class PythonServerStructureGenerator( private val shape: StructureShape, ) : StructureGenerator(model, symbolProvider, writer, shape) { - private val pyo3Symbols = listOf(PythonServerCargoDependency.PyO3.asType()) + private val pyo3Symbols = listOf(PythonServerCargoDependency.PyO3.toType()) override fun renderStructure() { if (shape.hasTrait()) { diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGenerator.kt index 9d00178aac..f2b6ddef81 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGenerator.kt @@ -19,7 +19,6 @@ import software.amazon.smithy.model.traits.HttpTrait import software.amazon.smithy.model.traits.SensitiveTrait import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.plus import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate @@ -35,7 +34,7 @@ import java.util.Optional /** Models the ways status codes can be bound and sensitive. */ class StatusCodeSensitivity(private val sensitive: Boolean, runtimeConfig: RuntimeConfig) { private val codegenScope = arrayOf( - "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).asType(), + "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).toType(), ) /** Returns the type of the `MakeFmt`. */ @@ -65,7 +64,8 @@ data class GreedyLabel( /** Models the ways labels can be bound and sensitive. */ class LabelSensitivity(internal val labelIndexes: List, internal val greedyLabel: GreedyLabel?, runtimeConfig: RuntimeConfig) { - private val codegenScope = arrayOf("SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).asType()) + private val codegenScope = + arrayOf("SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).toType()) /** Returns the closure used during construction. */ fun closure(): Writable = writable { @@ -117,8 +117,8 @@ sealed class HeaderSensitivity( runtimeConfig: RuntimeConfig, ) { private val codegenScope = arrayOf( - "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).asType(), - "Http" to CargoDependency.Http.asType(), + "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).toType(), + "Http" to CargoDependency.Http.toType(), ) /** The case where `prefixHeaders` value is not sensitive. */ @@ -218,7 +218,8 @@ sealed class QuerySensitivity( val allKeysSensitive: Boolean, runtimeConfig: RuntimeConfig, ) { - private val codegenScope = arrayOf("SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).asType()) + private val codegenScope = + arrayOf("SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).toType()) /** The case where the `httpQueryParams` value is not sensitive. */ class NotSensitiveMapValue( @@ -306,8 +307,8 @@ class ServerHttpSensitivityGenerator( private val runtimeConfig: RuntimeConfig, ) { private val codegenScope = arrayOf( - "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).asType(), - "Http" to CargoDependency.Http.asType(), + "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).toType(), + "Http" to CargoDependency.Http.toType(), ) /** Constructs `StatusCodeSensitivity` of a `Shape` */ diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationGenerator.kt index b34685f7b8..2636440399 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationGenerator.kt @@ -8,7 +8,6 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.documentShape import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate @@ -25,7 +24,7 @@ class ServerOperationGenerator( private val codegenScope = arrayOf( "SmithyHttpServer" to - ServerCargoDependency.SmithyHttpServer(runtimeConfig).asType(), + ServerCargoDependency.SmithyHttpServer(runtimeConfig).toType(), ) private val symbolProvider = codegenContext.symbolProvider private val model = codegenContext.model diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationHandlerGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationHandlerGenerator.kt index 5a3c93b2be..fb8501fd10 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationHandlerGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationHandlerGenerator.kt @@ -8,7 +8,6 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext @@ -37,11 +36,11 @@ open class ServerOperationHandlerGenerator( private val symbolProvider = codegenContext.symbolProvider private val runtimeConfig = codegenContext.runtimeConfig private val codegenScope = arrayOf( - "AsyncTrait" to ServerCargoDependency.AsyncTrait.asType(), - "Tower" to ServerCargoDependency.Tower.asType(), - "FuturesUtil" to ServerCargoDependency.FuturesUtil.asType(), - "SmithyHttp" to CargoDependency.SmithyHttp(runtimeConfig).asType(), - "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).asType(), + "AsyncTrait" to ServerCargoDependency.AsyncTrait.toType(), + "Tower" to ServerCargoDependency.Tower.toType(), + "FuturesUtil" to ServerCargoDependency.FuturesUtil.toType(), + "SmithyHttp" to CargoDependency.smithyHttp(runtimeConfig).toType(), + "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).toType(), "Phantom" to ServerRuntimeType.Phantom, "ServerOperationHandler" to ServerRuntimeType.OperationHandler(runtimeConfig), "http" to RuntimeType.http, diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGenerator.kt index 1952c0f934..e6e1c1ac40 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerOperationRegistryGenerator.kt @@ -13,7 +13,6 @@ import software.amazon.smithy.rust.codegen.core.rustlang.DependencyScope import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWords import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock import software.amazon.smithy.rust.codegen.core.rustlang.rustBlockTemplate @@ -60,9 +59,9 @@ class ServerOperationRegistryGenerator( private val runtimeConfig = codegenContext.runtimeConfig private val codegenScope = arrayOf( "Router" to ServerRuntimeType.Router(runtimeConfig), - "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).asType(), + "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).toType(), "ServerOperationHandler" to ServerRuntimeType.OperationHandler(runtimeConfig), - "Tower" to ServerCargoDependency.Tower.asType(), + "Tower" to ServerCargoDependency.Tower.toType(), "Phantom" to ServerRuntimeType.Phantom, "StdError" to RuntimeType.StdError, "Display" to RuntimeType.Display, @@ -159,8 +158,8 @@ ${operationImplementationStubs(operations)} "Router" to ServerRuntimeType.Router(runtimeConfig), // These should be dev-dependencies. Not all sSDKs depend on `Hyper` (only those that convert the body // `to_bytes`), and none depend on `tokio`. - "Tokio" to ServerCargoDependency.TokioDev.asType(), - "Hyper" to CargoDependency.Hyper.copy(scope = DependencyScope.Dev).asType(), + "Tokio" to ServerCargoDependency.TokioDev.toType(), + "Hyper" to CargoDependency.Hyper.copy(scope = DependencyScope.Dev).toType(), ) } @@ -400,6 +399,6 @@ ${operationImplementationStubs(operations)} this, symbolProvider.toSymbol(this).name, serviceName, - ServerCargoDependency.SmithyHttpServer(runtimeConfig).asType().member("routing::request_spec"), + ServerCargoDependency.SmithyHttpServer(runtimeConfig).toType().member("routing::request_spec"), ) } diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGeneratorV2.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGeneratorV2.kt index c4420fced5..7b553ee119 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGeneratorV2.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGeneratorV2.kt @@ -11,7 +11,6 @@ import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWords import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.documentShape import software.amazon.smithy.rust.codegen.core.rustlang.join import software.amazon.smithy.rust.codegen.core.rustlang.rust @@ -28,14 +27,14 @@ class ServerServiceGeneratorV2( private val protocol: ServerProtocol, ) { private val runtimeConfig = codegenContext.runtimeConfig - private val smithyHttpServer = ServerCargoDependency.SmithyHttpServer(runtimeConfig).asType() + private val smithyHttpServer = ServerCargoDependency.SmithyHttpServer(runtimeConfig).toType() private val codegenScope = arrayOf( - "Bytes" to CargoDependency.Bytes.asType(), - "Http" to CargoDependency.Http.asType(), - "HttpBody" to CargoDependency.HttpBody.asType(), + "Bytes" to CargoDependency.Bytes.toType(), + "Http" to CargoDependency.Http.toType(), + "HttpBody" to CargoDependency.HttpBody.toType(), "SmithyHttpServer" to smithyHttpServer, - "Tower" to CargoDependency.Tower.asType(), + "Tower" to CargoDependency.Tower.toType(), ) private val model = codegenContext.model private val symbolProvider = codegenContext.symbolProvider diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerResponseBindingGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerResponseBindingGenerator.kt index 020f558ce9..2a030d1070 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerResponseBindingGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerResponseBindingGenerator.kt @@ -13,7 +13,6 @@ 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.writable import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType -import software.amazon.smithy.rust.codegen.core.smithy.generators.builderSymbol import software.amazon.smithy.rust.codegen.core.smithy.generators.http.HttpBindingCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.http.HttpBindingGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.http.HttpBindingSection diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt index a865f27220..cf981edb73 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt @@ -31,7 +31,6 @@ import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWords 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.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.escape import software.amazon.smithy.rust.codegen.core.rustlang.rust import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock @@ -103,13 +102,13 @@ class ServerProtocolTestGenerator( private val codegenScope = arrayOf( "Bytes" to RuntimeType.Bytes, - "SmithyHttp" to CargoDependency.SmithyHttp(codegenContext.runtimeConfig).asType(), - "Http" to CargoDependency.Http.asType(), - "Hyper" to CargoDependency.Hyper.asType(), - "Tokio" to ServerCargoDependency.TokioDev.asType(), - "Tower" to CargoDependency.Tower.asType(), - "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(codegenContext.runtimeConfig).asType(), - "AssertEq" to CargoDependency.PrettyAssertions.asType().member("assert_eq!"), + "SmithyHttp" to CargoDependency.smithyHttp(codegenContext.runtimeConfig).toType(), + "Http" to CargoDependency.Http.toType(), + "Hyper" to CargoDependency.Hyper.toType(), + "Tokio" to ServerCargoDependency.TokioDev.toType(), + "Tower" to CargoDependency.Tower.toType(), + "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(codegenContext.runtimeConfig).toType(), + "AssertEq" to CargoDependency.PrettyAssertions.toType().member("assert_eq!"), "Router" to ServerRuntimeType.Router(codegenContext.runtimeConfig), ) diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpBoundProtocolGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpBoundProtocolGenerator.kt index a8a6e1608f..01f498db1a 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpBoundProtocolGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpBoundProtocolGenerator.kt @@ -31,7 +31,6 @@ 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.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.Writable -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.conditionalBlock import software.amazon.smithy.rust.codegen.core.rustlang.escape import software.amazon.smithy.rust.codegen.core.rustlang.render @@ -129,21 +128,21 @@ private class ServerHttpBoundProtocolTraitImplGenerator( private val typeConversionGenerator = TypeConversionGenerator(model, symbolProvider, runtimeConfig) private val codegenScope = arrayOf( - "AsyncTrait" to ServerCargoDependency.AsyncTrait.asType(), + "AsyncTrait" to ServerCargoDependency.AsyncTrait.toType(), "Cow" to ServerRuntimeType.Cow, "DateTime" to RuntimeType.DateTime(runtimeConfig), - "FormUrlEncoded" to ServerCargoDependency.FormUrlEncoded.asType(), - "HttpBody" to CargoDependency.HttpBody.asType(), - "header_util" to CargoDependency.SmithyHttp(runtimeConfig).asType().member("header"), - "Hyper" to CargoDependency.Hyper.asType(), - "LazyStatic" to CargoDependency.LazyStatic.asType(), - "Mime" to ServerCargoDependency.Mime.asType(), - "Nom" to ServerCargoDependency.Nom.asType(), - "OnceCell" to ServerCargoDependency.OnceCell.asType(), - "PercentEncoding" to CargoDependency.PercentEncoding.asType(), - "Regex" to CargoDependency.Regex.asType(), - "SmithyHttp" to CargoDependency.SmithyHttp(runtimeConfig).asType(), - "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).asType(), + "FormUrlEncoded" to ServerCargoDependency.FormUrlEncoded.toType(), + "HttpBody" to CargoDependency.HttpBody.toType(), + "header_util" to CargoDependency.smithyHttp(runtimeConfig).toType().member("header"), + "Hyper" to CargoDependency.Hyper.toType(), + "LazyStatic" to CargoDependency.LazyStatic.toType(), + "Mime" to ServerCargoDependency.Mime.toType(), + "Nom" to ServerCargoDependency.Nom.toType(), + "OnceCell" to ServerCargoDependency.OnceCell.toType(), + "PercentEncoding" to CargoDependency.PercentEncoding.toType(), + "Regex" to CargoDependency.Regex.toType(), + "SmithyHttp" to CargoDependency.smithyHttp(runtimeConfig).toType(), + "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(runtimeConfig).toType(), "RuntimeError" to ServerRuntimeType.RuntimeError(runtimeConfig), "RequestRejection" to ServerRuntimeType.RequestRejection(runtimeConfig), "ResponseRejection" to ServerRuntimeType.ResponseRejection(runtimeConfig), @@ -1051,7 +1050,7 @@ private class ServerHttpBoundProtocolTraitImplGenerator( """ let v = <_ as #T>::parse_smithy_primitive(&v)?; """.trimIndent(), - CargoDependency.SmithyTypes(runtimeConfig).asType().member("primitive::Parse"), + CargoDependency.smithyTypes(runtimeConfig).toType().member("primitive::Parse"), ) } } @@ -1249,10 +1248,10 @@ private class ServerHttpBoundProtocolTraitImplGenerator( } return when (codegenContext.protocol) { RestJson1Trait.ID, AwsJson1_0Trait.ID, AwsJson1_1Trait.ID -> { - CargoDependency.smithyJson(runtimeConfig).asType().member("deserialize::error::DeserializeError") + CargoDependency.smithyJson(runtimeConfig).toType().member("deserialize::error::DeserializeError") } RestXmlTrait.ID -> { - CargoDependency.smithyXml(runtimeConfig).asType().member("decode").member("XmlDecodeError") + CargoDependency.smithyXml(runtimeConfig).toType().member("decode").member("XmlDecodeError") } else -> { TODO("Protocol ${codegenContext.protocol} not supported yet") diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGeneratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGeneratorTest.kt index 55b7c462ac..d00dcd842c 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGeneratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerHttpSensitivityGeneratorTest.kt @@ -9,7 +9,6 @@ import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import software.amazon.smithy.model.traits.HttpTrait import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency -import software.amazon.smithy.rust.codegen.core.rustlang.asType import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.testutil.TestRuntimeConfig import software.amazon.smithy.rust.codegen.core.testutil.TestWorkspace @@ -23,8 +22,8 @@ import software.amazon.smithy.rust.codegen.server.smithy.testutil.serverTestSymb class ServerHttpSensitivityGeneratorTest { private val codegenScope = arrayOf( - "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(TestRuntimeConfig).asType(), - "Http" to CargoDependency.Http.asType(), + "SmithyHttpServer" to ServerCargoDependency.SmithyHttpServer(TestRuntimeConfig).toType(), + "Http" to CargoDependency.Http.toType(), ) @Test diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/serialize/EventStreamMarshallerGeneratorTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/serialize/EventStreamMarshallerGeneratorTest.kt index 9b87304554..4449caae37 100644 --- a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/serialize/EventStreamMarshallerGeneratorTest.kt +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/serialize/EventStreamMarshallerGeneratorTest.kt @@ -47,7 +47,7 @@ class EventStreamMarshallerGeneratorTest { ) test.project.lib { - val protocolTestHelpers = CargoDependency.SmithyProtocolTestHelpers(TestRuntimeConfig) + val protocolTestHelpers = CargoDependency.smithyProtocolTestHelpers(TestRuntimeConfig) .copy(scope = DependencyScope.Compile) rustTemplate( """ @@ -72,8 +72,8 @@ class EventStreamMarshallerGeneratorTest { HeaderValue::String(value.into()) } """, - "validate_body" to protocolTestHelpers.rustName("validate_body"), - "MediaType" to protocolTestHelpers.rustName("MediaType"), + "validate_body" to protocolTestHelpers.toType().member("validate_body"), + "MediaType" to protocolTestHelpers.toType().member("MediaType"), ) unitTest(