Loading CHANGELOG.next.toml +7 −1 Original line number Diff line number Diff line Loading @@ -11,6 +11,12 @@ # meta = { "breaking" = false, "tada" = false, "bug" = false } # author = "rcoh" [[smithy-rs]] message = "Refactor `Document` shape parser generation" references = ["smithy-rs#1123"] meta = { "breaking" = false, "tada" = false, "bug" = false } author = "rcoh" [[aws-sdk-rust]] message = """ Moved the following re-exports into a `types` module for all services: Loading codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerRequestBindingGenerator.kt +1 −4 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators.http import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.rustlang.RustWriter import software.amazon.smithy.rust.codegen.smithy.CodegenContext Loading @@ -29,14 +28,12 @@ class ServerRequestBindingGenerator( operationShape: OperationShape, binding: HttpBindingDescriptor, errorT: RuntimeType, structuredHandler: RustWriter.(String) -> Unit, docHandler: RustWriter.(String) -> Unit structuredHandler: RustWriter.(String) -> Unit ): RuntimeType = httpBindingGenerator.generateDeserializePayloadFn( operationShape, binding, errorT, structuredHandler, docHandler, HttpMessageType.REQUEST ) } codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpProtocolGenerator.kt +0 −7 Original line number Diff line number Diff line Loading @@ -608,12 +608,6 @@ private class ServerHttpProtocolImplGenerator( return when (binding.location) { HttpLocation.HEADER -> writable { serverRenderHeaderParser(this, binding, operationShape) } HttpLocation.PAYLOAD -> { val docShapeHandler: RustWriter.(String) -> Unit = { body -> rust( "#T($body)", structuredDataParser.documentParser(operationShape), ) } val structureShapeHandler: RustWriter.(String) -> Unit = { body -> rust("#T($body)", structuredDataParser.payloadParser(binding.member)) } Loading @@ -621,7 +615,6 @@ private class ServerHttpProtocolImplGenerator( operationShape, binding, errorSymbol, docHandler = docShapeHandler, structuredHandler = structureShapeHandler ) return if (binding.member.isStreaming(model)) { Loading codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/http/HttpBindingGenerator.kt +4 −9 Original line number Diff line number Diff line Loading @@ -174,10 +174,8 @@ class HttpBindingGenerator( operationShape: OperationShape, binding: HttpBindingDescriptor, errorT: RuntimeType, // Deserialize a single structure or union member marked as a payload structuredHandler: RustWriter.(String) -> Unit, // Deserialize a document type marked as a payload docHandler: RustWriter.(String) -> Unit, // Deserialize a single structure, union or document member marked as a payload payloadParser: RustWriter.(String) -> Unit, httpMessageType: HttpMessageType = HttpMessageType.RESPONSE ): RuntimeType { check(binding.location == HttpBinding.Location.PAYLOAD) Loading @@ -204,8 +202,7 @@ class HttpBindingGenerator( deserializePayloadBody( binding, errorT, structuredHandler = structuredHandler, docShapeHandler = docHandler, structuredHandler = payloadParser, httpMessageType ) } Loading Loading @@ -253,7 +250,6 @@ class HttpBindingGenerator( binding: HttpBindingDescriptor, errorSymbol: RuntimeType, structuredHandler: RustWriter.(String) -> Unit, docShapeHandler: RustWriter.(String) -> Unit, httpMessageType: HttpMessageType = HttpMessageType.RESPONSE ) { val member = binding.member Loading @@ -262,7 +258,7 @@ class HttpBindingGenerator( // of an empty instance of the response type. withBlock("(!body.is_empty()).then(||{", "}).transpose()") { when (targetShape) { is StructureShape, is UnionShape -> this.structuredHandler("body") is StructureShape, is UnionShape, is DocumentShape -> this.structuredHandler("body") is StringShape -> { when (httpMessageType) { HttpMessageType.RESPONSE -> { Loading @@ -288,7 +284,6 @@ class HttpBindingGenerator( "Ok(#T::new(body))", RuntimeType.Blob(runtimeConfig) ) is DocumentShape -> this.docShapeHandler("body") // `httpPayload` can be applied to set/map/list shapes. // However, none of the AWS protocols support it. // Smithy CLI will refuse to build the model if you apply the trait to these shapes, so this branch Loading codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/http/ResponseBindingGenerator.kt +2 −4 Original line number Diff line number Diff line Loading @@ -29,13 +29,11 @@ class ResponseBindingGenerator( operationShape: OperationShape, binding: HttpBindingDescriptor, errorT: RuntimeType, structuredHandler: RustWriter.(String) -> Unit, docHandler: RustWriter.(String) -> Unit payloadParser: RustWriter.(String) -> Unit ): RuntimeType = httpBindingGenerator.generateDeserializePayloadFn( operationShape, binding, errorT, structuredHandler, docHandler payloadParser ) } Loading
CHANGELOG.next.toml +7 −1 Original line number Diff line number Diff line Loading @@ -11,6 +11,12 @@ # meta = { "breaking" = false, "tada" = false, "bug" = false } # author = "rcoh" [[smithy-rs]] message = "Refactor `Document` shape parser generation" references = ["smithy-rs#1123"] meta = { "breaking" = false, "tada" = false, "bug" = false } author = "rcoh" [[aws-sdk-rust]] message = """ Moved the following re-exports into a `types` module for all services: Loading
codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/http/ServerRequestBindingGenerator.kt +1 −4 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ package software.amazon.smithy.rust.codegen.server.smithy.generators.http import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.rust.codegen.rustlang.RustWriter import software.amazon.smithy.rust.codegen.smithy.CodegenContext Loading @@ -29,14 +28,12 @@ class ServerRequestBindingGenerator( operationShape: OperationShape, binding: HttpBindingDescriptor, errorT: RuntimeType, structuredHandler: RustWriter.(String) -> Unit, docHandler: RustWriter.(String) -> Unit structuredHandler: RustWriter.(String) -> Unit ): RuntimeType = httpBindingGenerator.generateDeserializePayloadFn( operationShape, binding, errorT, structuredHandler, docHandler, HttpMessageType.REQUEST ) }
codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpProtocolGenerator.kt +0 −7 Original line number Diff line number Diff line Loading @@ -608,12 +608,6 @@ private class ServerHttpProtocolImplGenerator( return when (binding.location) { HttpLocation.HEADER -> writable { serverRenderHeaderParser(this, binding, operationShape) } HttpLocation.PAYLOAD -> { val docShapeHandler: RustWriter.(String) -> Unit = { body -> rust( "#T($body)", structuredDataParser.documentParser(operationShape), ) } val structureShapeHandler: RustWriter.(String) -> Unit = { body -> rust("#T($body)", structuredDataParser.payloadParser(binding.member)) } Loading @@ -621,7 +615,6 @@ private class ServerHttpProtocolImplGenerator( operationShape, binding, errorSymbol, docHandler = docShapeHandler, structuredHandler = structureShapeHandler ) return if (binding.member.isStreaming(model)) { Loading
codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/http/HttpBindingGenerator.kt +4 −9 Original line number Diff line number Diff line Loading @@ -174,10 +174,8 @@ class HttpBindingGenerator( operationShape: OperationShape, binding: HttpBindingDescriptor, errorT: RuntimeType, // Deserialize a single structure or union member marked as a payload structuredHandler: RustWriter.(String) -> Unit, // Deserialize a document type marked as a payload docHandler: RustWriter.(String) -> Unit, // Deserialize a single structure, union or document member marked as a payload payloadParser: RustWriter.(String) -> Unit, httpMessageType: HttpMessageType = HttpMessageType.RESPONSE ): RuntimeType { check(binding.location == HttpBinding.Location.PAYLOAD) Loading @@ -204,8 +202,7 @@ class HttpBindingGenerator( deserializePayloadBody( binding, errorT, structuredHandler = structuredHandler, docShapeHandler = docHandler, structuredHandler = payloadParser, httpMessageType ) } Loading Loading @@ -253,7 +250,6 @@ class HttpBindingGenerator( binding: HttpBindingDescriptor, errorSymbol: RuntimeType, structuredHandler: RustWriter.(String) -> Unit, docShapeHandler: RustWriter.(String) -> Unit, httpMessageType: HttpMessageType = HttpMessageType.RESPONSE ) { val member = binding.member Loading @@ -262,7 +258,7 @@ class HttpBindingGenerator( // of an empty instance of the response type. withBlock("(!body.is_empty()).then(||{", "}).transpose()") { when (targetShape) { is StructureShape, is UnionShape -> this.structuredHandler("body") is StructureShape, is UnionShape, is DocumentShape -> this.structuredHandler("body") is StringShape -> { when (httpMessageType) { HttpMessageType.RESPONSE -> { Loading @@ -288,7 +284,6 @@ class HttpBindingGenerator( "Ok(#T::new(body))", RuntimeType.Blob(runtimeConfig) ) is DocumentShape -> this.docShapeHandler("body") // `httpPayload` can be applied to set/map/list shapes. // However, none of the AWS protocols support it. // Smithy CLI will refuse to build the model if you apply the trait to these shapes, so this branch Loading
codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/http/ResponseBindingGenerator.kt +2 −4 Original line number Diff line number Diff line Loading @@ -29,13 +29,11 @@ class ResponseBindingGenerator( operationShape: OperationShape, binding: HttpBindingDescriptor, errorT: RuntimeType, structuredHandler: RustWriter.(String) -> Unit, docHandler: RustWriter.(String) -> Unit payloadParser: RustWriter.(String) -> Unit ): RuntimeType = httpBindingGenerator.generateDeserializePayloadFn( operationShape, binding, errorT, structuredHandler, docHandler payloadParser ) }