Skip to content

Commit

Permalink
Fix formatting and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Fahad Zubair committed Sep 4, 2024
1 parent f2c11b8 commit 829cc8d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,10 @@ class CborParserGenerator(
return protocolFunctions.deserializeFn(shape, fnNameSuffix = "payload") { fnName ->
rustTemplate(
"""
pub(crate) fn $fnName(value: &[u8]) -> #{Result}<#{ReturnType}, #{Error}> {
let decoder = &mut #{Decoder}::new(value);
#{DeserializeMember}
}
pub(crate) fn $fnName(value: &[u8]) -> #{Result}<#{ReturnType}, #{Error}> {
let decoder = &mut #{Decoder}::new(value);
#{DeserializeMember}
}
""",
"ReturnType" to returnSymbol.symbol,
"DeserializeMember" to deserializeMember(member),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ class CborSerializerGenerator(
}

val httpDocumentMembers = httpBindingResolver.requestMembers(operationShape, HttpLocation.DOCUMENT)

val inputShape = operationShape.inputShape(model)
return protocolFunctions.serializeFn(operationShape, fnNameSuffix = "input") { fnName ->
rustBlockTemplate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ open class ServerCodegenVisitor(
.let { AttachValidationExceptionToConstrainedOperationInputs.transform(it, settings) }
// Tag aggregate shapes reachable from operation input
.let(ShapesReachableFromOperationInputTagger::transform)
// Remove traits that are not supported by the chosen protocol
// Remove traits that are not supported by the chosen protocol.
.let { ServerProtocolBasedTransformationFactory.transform(it, settings) }
// Normalize event stream operations
.let(EventStreamNormalizer::transform)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ import software.amazon.smithy.rust.codegen.core.smithy.protocols.serialize.Value
import software.amazon.smithy.rust.codegen.server.smithy.ServerCodegenContext
import software.amazon.smithy.rust.codegen.server.smithy.workingWithPublicConstrainedWrapperTupleType

/**
* Constrained shapes are wrapped in a Rust tuple struct that implements all necessary checks. However,
* for serialization purposes, the inner type of the constrained shape is used for serialization.
*
* The `BeforeSerializingMemberCborCustomization` class generates a reference to the inner type when the shape being
* code-generated is constrained and the `publicConstrainedTypes` codegen flag is set.
*/
class BeforeSerializingMemberCborCustomization(private val codegenContext: ServerCodegenContext) : CborSerializerCustomization() {
override fun section(section: CborSerializerSection): Writable =
when (section) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package software.amazon.smithy.rust.codegen.server.smithy.protocols.serialize

import org.junit.jupiter.api.Test
import software.amazon.smithy.model.shapes.ShapeId
import software.amazon.smithy.rust.codegen.core.testutil.IntegrationTestParams
import software.amazon.smithy.rust.codegen.core.testutil.ServerAdditionalSettings
import software.amazon.smithy.rust.codegen.server.smithy.ModelProtocol
import software.amazon.smithy.rust.codegen.server.smithy.loadSmithyConstraintsModelForProtocol
import software.amazon.smithy.rust.codegen.server.smithy.removeOperations
import software.amazon.smithy.rust.codegen.server.smithy.testutil.serverIntegrationTest

class CborConstraintsIntegrationTest {
Expand Down

0 comments on commit 829cc8d

Please sign in to comment.