Skip to content

Commit 9531447

Browse files
committed
merge fix
1 parent 5f8330f commit 9531447

File tree

7 files changed

+24
-12
lines changed

7 files changed

+24
-12
lines changed

codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGenerator.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustBlock
3333
import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate
3434
import software.amazon.smithy.rust.codegen.core.rustlang.withBlock
3535
import software.amazon.smithy.rust.codegen.core.rustlang.writable
36+
import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType
3637
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport
38+
import software.amazon.smithy.rust.codegen.core.testutil.testDependenciesOnly
3739
import software.amazon.smithy.rust.codegen.core.util.dq
3840
import software.amazon.smithy.rust.codegen.core.util.getTrait
3941
import software.amazon.smithy.rust.codegen.core.util.hasTrait
@@ -173,8 +175,14 @@ class DefaultProtocolTestGenerator(
173175
}
174176
testModuleWriter.write("Test ID: ${testCase.id}")
175177
testModuleWriter.newlinePrefix = ""
178+
176179
Attribute.TokioTest.render(testModuleWriter)
177180
Attribute.TracedTest.render(testModuleWriter)
181+
// The `#[traced_test]` macro desugars to using `tracing`, so we need to depend on the latter explicitly in
182+
// case the code rendered by the test does not make use of `tracing` at all.
183+
val tracingDevDependency = testDependenciesOnly { addDependency(CargoDependency.Tracing.toDevDependency()) }
184+
testModuleWriter.rustTemplate("#{TracingDevDependency:W}", "TracingDevDependency" to tracingDevDependency)
185+
178186
val action = when (testCase) {
179187
is HttpResponseTestCase -> Action.Response
180188
is HttpRequestTestCase -> Action.Request

codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/ClientProtocolLoader.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import software.amazon.smithy.aws.traits.protocols.Ec2QueryTrait
1313
import software.amazon.smithy.aws.traits.protocols.RestJson1Trait
1414
import software.amazon.smithy.aws.traits.protocols.RestXmlTrait
1515
import software.amazon.smithy.model.shapes.ServiceShape
16-
import software.amazon.smithy.protocols.traits.Rpcv2Trait
16+
import software.amazon.smithy.protocol.traits.Rpcv2CborTrait
1717
import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext
1818
import software.amazon.smithy.rust.codegen.client.smithy.generators.OperationGenerator
1919
import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext
@@ -42,7 +42,7 @@ class ClientProtocolLoader(supportedProtocols: ProtocolMap<OperationGenerator, C
4242
Ec2QueryTrait.ID to ClientEc2QueryFactory(),
4343
RestJson1Trait.ID to ClientRestJsonFactory(),
4444
RestXmlTrait.ID to ClientRestXmlFactory(),
45-
Rpcv2Trait.ID to ClientRpcV2Factory(),
45+
Rpcv2CborTrait.ID to ClientRpcV2CborFactory(),
4646
)
4747
val Default = ClientProtocolLoader(DefaultProtocols)
4848
}
@@ -120,12 +120,11 @@ class ClientRestXmlFactory(
120120
override fun support(): ProtocolSupport = CLIENT_PROTOCOL_SUPPORT
121121
}
122122

123-
// TODO(rpcv2): Implement `ClientRpcV2Factory`
124-
class ClientRpcV2Factory() : ProtocolGeneratorFactory<HttpBoundProtocolGenerator, ClientCodegenContext> {
123+
class ClientRpcV2CborFactory : ProtocolGeneratorFactory<OperationGenerator, ClientCodegenContext> {
125124
override fun protocol(codegenContext: ClientCodegenContext): Protocol = RpcV2(codegenContext)
126125

127-
override fun buildProtocolGenerator(codegenContext: ClientCodegenContext): HttpBoundProtocolGenerator =
128-
HttpBoundProtocolGenerator(codegenContext, protocol(codegenContext))
126+
override fun buildProtocolGenerator(codegenContext: ClientCodegenContext): OperationGenerator =
127+
OperationGenerator(codegenContext, protocol(codegenContext))
129128

130129
override fun support(): ProtocolSupport = CLIENT_PROTOCOL_SUPPORT
131130
}

codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/AwsJson.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ open class AwsJson(
178178
rustTemplate(
179179
"""
180180
pub fn $fnName(payload: &#{Bytes}) -> Result<#{ErrorMetadataBuilder}, #{JsonError}> {
181-
#{json_errors}::parse_error_metadata(payload, &#{HeaderMap}::new())
181+
#{json_errors}::parse_error_metadata(payload, &#{Headers}::new())
182182
}
183183
""",
184184
*errorScope,

codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/RestJson.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ open class RestJson(val codegenContext: CodegenContext) : Protocol {
134134
rustTemplate(
135135
"""
136136
pub fn $fnName(payload: &#{Bytes}) -> Result<#{ErrorMetadataBuilder}, #{JsonError}> {
137-
#{json_errors}::parse_error_metadata(payload, &#{HeaderMap}::new())
137+
#{json_errors}::parse_error_metadata(payload, &#{Headers}::new())
138138
}
139139
""",
140140
*errorScope,

codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import software.amazon.smithy.protocoltests.traits.HttpResponseTestCase
2626
import software.amazon.smithy.protocoltests.traits.HttpResponseTestsTrait
2727
import software.amazon.smithy.rust.codegen.core.rustlang.Attribute
2828
import software.amazon.smithy.rust.codegen.core.rustlang.Attribute.Companion.allow
29+
import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency
2930
import software.amazon.smithy.rust.codegen.core.rustlang.RustMetadata
3031
import software.amazon.smithy.rust.codegen.core.rustlang.RustModule
3132
import software.amazon.smithy.rust.codegen.core.rustlang.RustReservedWords
@@ -42,6 +43,7 @@ import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext
4243
import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType
4344
import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport
4445
import software.amazon.smithy.rust.codegen.core.smithy.transformers.allErrors
46+
import software.amazon.smithy.rust.codegen.core.testutil.testDependenciesOnly
4547
import software.amazon.smithy.rust.codegen.core.util.dq
4648
import software.amazon.smithy.rust.codegen.core.util.getTrait
4749
import software.amazon.smithy.rust.codegen.core.util.hasStreamingMember
@@ -280,6 +282,10 @@ class ServerProtocolTestGenerator(
280282

281283
Attribute.TokioTest.render(testModuleWriter)
282284
Attribute.TracedTest.render(testModuleWriter)
285+
// The `#[traced_test]` macro desugars to using `tracing`, so we need to depend on the latter explicitly in
286+
// case the code rendered by the test does not make use of `tracing` at all.
287+
val tracingDevDependency = testDependenciesOnly { addDependency(CargoDependency.Tracing.toDevDependency()) }
288+
testModuleWriter.rustTemplate("#{TracingDevDependency:W}", "TracingDevDependency" to tracingDevDependency)
283289

284290
if (expectFail(testCase)) {
285291
testModuleWriter.writeWithNoFormatting("#[should_panic]")

codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerProtocolLoader.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import software.amazon.smithy.rust.codegen.core.util.isOutputEventStream
2121
import software.amazon.smithy.rust.codegen.server.smithy.ServerCodegenContext
2222
import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerProtocolGenerator
2323

24-
class StreamPayloadSerializerCustomization() : ServerHttpBoundProtocolCustomization() {
24+
class StreamPayloadSerializerCustomization : ServerHttpBoundProtocolCustomization() {
2525
override fun section(section: ServerHttpBoundProtocolSection): Writable =
2626
when (section) {
2727
is ServerHttpBoundProtocolSection.WrapStreamPayload ->
@@ -81,7 +81,7 @@ class ServerProtocolLoader(supportedProtocols: ProtocolMap<ServerProtocolGenerat
8181
additionalServerHttpBoundProtocolCustomizations = listOf(StreamPayloadSerializerCustomization()),
8282
),
8383
// TODO `StreamPayloadSerializerCustomization`
84-
Rpcv2CborTrait.ID to ServerRpcV2Factory(),
84+
Rpcv2CborTrait.ID to ServerRpcV2CborFactory(),
8585
)
8686
}
8787
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGenerat
1111
import software.amazon.smithy.rust.codegen.server.smithy.ServerCodegenContext
1212
import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerRpcV2Protocol
1313

14-
class ServerRpcV2Factory : ProtocolGeneratorFactory<ServerHttpBoundProtocolGenerator, ServerCodegenContext> {
14+
class ServerRpcV2CborFactory : ProtocolGeneratorFactory<ServerHttpBoundProtocolGenerator, ServerCodegenContext> {
1515
override fun protocol(codegenContext: ServerCodegenContext): Protocol =
1616
ServerRpcV2Protocol(codegenContext)
1717

1818
override fun buildProtocolGenerator(codegenContext: ServerCodegenContext): ServerHttpBoundProtocolGenerator =
1919
ServerHttpBoundProtocolGenerator(codegenContext, ServerRpcV2Protocol(codegenContext))
2020

2121
override fun support(): ProtocolSupport {
22-
// TODO(): Implement `ServerRpcV2Factory.support`
2322
return ProtocolSupport(
2423
/* Client support */
2524
requestSerialization = false,

0 commit comments

Comments
 (0)