Loading codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolGenerator.kt +3 −3 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientGenerator import software.amazon.smithy.rust.codegen.client.smithy.generators.client.fluentBuilderType import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpBoundProtocolTraitImplGenerator import software.amazon.smithy.rust.codegen.core.rustlang.Attribute import software.amazon.smithy.rust.codegen.core.rustlang.Attribute.Companion.derive import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter Loading @@ -23,7 +24,6 @@ import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSectio import software.amazon.smithy.rust.codegen.core.smithy.customize.writeCustomizations import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolTraitImplGenerator import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol import software.amazon.smithy.rust.codegen.core.util.inputShape Loading @@ -35,8 +35,8 @@ open class ClientProtocolGenerator( * This is the serializer side of request dispatch */ private val makeOperationGenerator: MakeOperationGenerator, private val traitGenerator: ProtocolTraitImplGenerator, ) : ProtocolGenerator(codegenContext, protocol, traitGenerator) { private val traitGenerator: HttpBoundProtocolTraitImplGenerator, ) : ProtocolGenerator(codegenContext, protocol) { /** * Render all code required for serializing requests and deserializing responses for the operation * Loading codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt +3 −4 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustom import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.smithy.customize.writeCustomizations import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolTraitImplGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.setterName import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingDescriptor import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBoundProtocolPayloadGenerator Loading Loading @@ -62,10 +61,10 @@ class HttpBoundProtocolGenerator( HttpBoundProtocolTraitImplGenerator(codegenContext, protocol), ) class HttpBoundProtocolTraitImplGenerator( open class HttpBoundProtocolTraitImplGenerator( private val codegenContext: ClientCodegenContext, private val protocol: Protocol, ) : ProtocolTraitImplGenerator { ) { private val symbolProvider = codegenContext.symbolProvider private val model = codegenContext.model private val runtimeConfig = codegenContext.runtimeConfig Loading Loading @@ -100,7 +99,7 @@ class HttpBoundProtocolTraitImplGenerator( ) } override fun generateTraitImpls( open fun generateTraitImpls( operationWriter: RustWriter, operationShape: OperationShape, customizations: List<OperationCustomization>, Loading codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGeneratorTest.kt +3 −3 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.ClientCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpBoundProtocolTraitImplGenerator import software.amazon.smithy.rust.codegen.client.testutil.clientIntegrationTest import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.escape Loading @@ -23,7 +24,6 @@ import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolPayloadGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolTraitImplGenerator import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGeneratorFactory import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolMap Loading @@ -44,9 +44,9 @@ private class TestProtocolPayloadGenerator(private val body: String) : ProtocolP } private class TestProtocolTraitImplGenerator( private val codegenContext: CodegenContext, private val codegenContext: ClientCodegenContext, private val correctResponse: String, ) : ProtocolTraitImplGenerator { ) : HttpBoundProtocolTraitImplGenerator(codegenContext, RestJson(codegenContext)) { private val symbolProvider = codegenContext.symbolProvider override fun generateTraitImpls( Loading codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolGenerator.kt +0 −21 Original line number Diff line number Diff line Loading @@ -8,7 +8,6 @@ package software.amazon.smithy.rust.codegen.core.smithy.generators.protocol import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol /** Loading Loading @@ -46,21 +45,6 @@ interface ProtocolPayloadGenerator { fun generatePayload(writer: RustWriter, self: String, operationShape: OperationShape) } /** * Protocol Trait implementation generator * * **Note:** There is only one real implementation of this interface. The other implementation is test-only. * All protocols use the same class. * * Protocols implement one of two traits to enable parsing HTTP responses: * 1. `ParseHttpResponse`: Streaming binary operations * 2. `ParseStrictResponse`: Non-streaming operations for the body must be "strict" (as in, not lazy) where the parser * must have the complete body to return a result. */ interface ProtocolTraitImplGenerator { fun generateTraitImpls(operationWriter: RustWriter, operationShape: OperationShape, customizations: List<OperationCustomization>) } /** * Class providing scaffolding for HTTP based protocols that must build an HTTP request (headers / URL) and a body. */ Loading @@ -72,11 +56,6 @@ abstract class ProtocolGenerator( * and an output shape is build from an `http::Response`. */ private val protocol: Protocol, /** * Operations generate implementations of ParseHttpResponse or ParseStrictResponse. * This is the deserializer side of request dispatch (parsing the response) */ private val traitGenerator: ProtocolTraitImplGenerator, ) { protected val symbolProvider = codegenContext.symbolProvider protected val model = codegenContext.model Loading codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolGenerator.kt +3 −3 Original line number Diff line number Diff line Loading @@ -9,13 +9,13 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolTraitImplGenerator import software.amazon.smithy.rust.codegen.server.smithy.protocols.ServerHttpBoundProtocolTraitImplGenerator open class ServerProtocolGenerator( codegenContext: CodegenContext, val protocol: ServerProtocol, private val traitGenerator: ProtocolTraitImplGenerator, ) : ProtocolGenerator(codegenContext, protocol, traitGenerator) { private val traitGenerator: ServerHttpBoundProtocolTraitImplGenerator, ) : ProtocolGenerator(codegenContext, protocol) { /** * The server implementation uses this method to generate implementations of the `from_request` and `into_response` * traits for operation input and output shapes, respectively. Loading Loading
codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ClientProtocolGenerator.kt +3 −3 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.generators.client.FluentClientGenerator import software.amazon.smithy.rust.codegen.client.smithy.generators.client.fluentBuilderType import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpBoundProtocolTraitImplGenerator import software.amazon.smithy.rust.codegen.core.rustlang.Attribute import software.amazon.smithy.rust.codegen.core.rustlang.Attribute.Companion.derive import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter Loading @@ -23,7 +24,6 @@ import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSectio import software.amazon.smithy.rust.codegen.core.smithy.customize.writeCustomizations import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolTraitImplGenerator import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol import software.amazon.smithy.rust.codegen.core.util.inputShape Loading @@ -35,8 +35,8 @@ open class ClientProtocolGenerator( * This is the serializer side of request dispatch */ private val makeOperationGenerator: MakeOperationGenerator, private val traitGenerator: ProtocolTraitImplGenerator, ) : ProtocolGenerator(codegenContext, protocol, traitGenerator) { private val traitGenerator: HttpBoundProtocolTraitImplGenerator, ) : ProtocolGenerator(codegenContext, protocol) { /** * Render all code required for serializing requests and deserializing responses for the operation * Loading
codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/HttpBoundProtocolGenerator.kt +3 −4 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustom import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationSection import software.amazon.smithy.rust.codegen.core.smithy.customize.writeCustomizations import software.amazon.smithy.rust.codegen.core.smithy.generators.BuilderGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolTraitImplGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.setterName import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBindingDescriptor import software.amazon.smithy.rust.codegen.core.smithy.protocols.HttpBoundProtocolPayloadGenerator Loading Loading @@ -62,10 +61,10 @@ class HttpBoundProtocolGenerator( HttpBoundProtocolTraitImplGenerator(codegenContext, protocol), ) class HttpBoundProtocolTraitImplGenerator( open class HttpBoundProtocolTraitImplGenerator( private val codegenContext: ClientCodegenContext, private val protocol: Protocol, ) : ProtocolTraitImplGenerator { ) { private val symbolProvider = codegenContext.symbolProvider private val model = codegenContext.model private val runtimeConfig = codegenContext.runtimeConfig Loading Loading @@ -100,7 +99,7 @@ class HttpBoundProtocolTraitImplGenerator( ) } override fun generateTraitImpls( open fun generateTraitImpls( operationWriter: RustWriter, operationShape: OperationShape, customizations: List<OperationCustomization>, Loading
codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/protocol/ProtocolTestGeneratorTest.kt +3 −3 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.rust.codegen.client.smithy.ClientCodegenContext import software.amazon.smithy.rust.codegen.client.smithy.customize.ClientCodegenDecorator import software.amazon.smithy.rust.codegen.client.smithy.protocols.HttpBoundProtocolTraitImplGenerator import software.amazon.smithy.rust.codegen.client.testutil.clientIntegrationTest import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.rustlang.escape Loading @@ -23,7 +24,6 @@ import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolPayloadGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolTraitImplGenerator import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGeneratorFactory import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolMap Loading @@ -44,9 +44,9 @@ private class TestProtocolPayloadGenerator(private val body: String) : ProtocolP } private class TestProtocolTraitImplGenerator( private val codegenContext: CodegenContext, private val codegenContext: ClientCodegenContext, private val correctResponse: String, ) : ProtocolTraitImplGenerator { ) : HttpBoundProtocolTraitImplGenerator(codegenContext, RestJson(codegenContext)) { private val symbolProvider = codegenContext.symbolProvider override fun generateTraitImpls( Loading
codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/protocol/ProtocolGenerator.kt +0 −21 Original line number Diff line number Diff line Loading @@ -8,7 +8,6 @@ package software.amazon.smithy.rust.codegen.core.smithy.generators.protocol import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.customize.OperationCustomization import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol /** Loading Loading @@ -46,21 +45,6 @@ interface ProtocolPayloadGenerator { fun generatePayload(writer: RustWriter, self: String, operationShape: OperationShape) } /** * Protocol Trait implementation generator * * **Note:** There is only one real implementation of this interface. The other implementation is test-only. * All protocols use the same class. * * Protocols implement one of two traits to enable parsing HTTP responses: * 1. `ParseHttpResponse`: Streaming binary operations * 2. `ParseStrictResponse`: Non-streaming operations for the body must be "strict" (as in, not lazy) where the parser * must have the complete body to return a result. */ interface ProtocolTraitImplGenerator { fun generateTraitImpls(operationWriter: RustWriter, operationShape: OperationShape, customizations: List<OperationCustomization>) } /** * Class providing scaffolding for HTTP based protocols that must build an HTTP request (headers / URL) and a body. */ Loading @@ -72,11 +56,6 @@ abstract class ProtocolGenerator( * and an output shape is build from an `http::Response`. */ private val protocol: Protocol, /** * Operations generate implementations of ParseHttpResponse or ParseStrictResponse. * This is the deserializer side of request dispatch (parsing the response) */ private val traitGenerator: ProtocolTraitImplGenerator, ) { protected val symbolProvider = codegenContext.symbolProvider protected val model = codegenContext.model Loading
codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolGenerator.kt +3 −3 Original line number Diff line number Diff line Loading @@ -9,13 +9,13 @@ import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolGenerator import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolTraitImplGenerator import software.amazon.smithy.rust.codegen.server.smithy.protocols.ServerHttpBoundProtocolTraitImplGenerator open class ServerProtocolGenerator( codegenContext: CodegenContext, val protocol: ServerProtocol, private val traitGenerator: ProtocolTraitImplGenerator, ) : ProtocolGenerator(codegenContext, protocol, traitGenerator) { private val traitGenerator: ServerHttpBoundProtocolTraitImplGenerator, ) : ProtocolGenerator(codegenContext, protocol) { /** * The server implementation uses this method to generate implementations of the `from_request` and `into_response` * traits for operation input and output shapes, respectively. Loading