in codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/protocols/serialize/QuerySerializerGenerator.kt [66:130]
fun structMember(
context: Context<StructureShape>,
member: MemberShape,
symProvider: RustSymbolProvider
): MemberContext =
MemberContext(
context.writerExpression,
ValueExpression.Value("${context.valueExpression.name}.${symProvider.toMemberName(member)}"),
member
)
fun unionMember(
context: Context<UnionShape>,
variantReference: String,
member: MemberShape
): MemberContext =
MemberContext(
context.writerExpression,
ValueExpression.Reference(variantReference),
member
)
}
}
protected val model = codegenContext.model
protected val symbolProvider = codegenContext.symbolProvider
protected val runtimeConfig = codegenContext.runtimeConfig
private val mode = codegenContext.mode
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 serdeUtil = SerializerUtil(model)
private val codegenScope = arrayOf(
"String" to RuntimeType.String,
"Error" to serializerError,
"SdkBody" to RuntimeType.sdkBody(runtimeConfig),
"QueryWriter" to smithyQuery.member("QueryWriter"),
"QueryValueWriter" to smithyQuery.member("QueryValueWriter"),
)
private val operationSerModule = RustModule.private("operation_ser")
private val querySerModule = RustModule.private("query_ser")
abstract val protocolName: String
abstract fun MemberShape.queryKeyName(prioritizedFallback: String? = null): String
abstract fun MemberShape.isFlattened(): Boolean
override fun documentSerializer(): RuntimeType {
TODO("$protocolName doesn't support document types")
}
override fun payloadSerializer(member: MemberShape): RuntimeType {
// TODO(EventStream): Query payload serialization is required for RPC initial message as well as for message
// frames that have a struct/union type.
TODO("$protocolName doesn't support payload serialization yet")
}
override fun unsetStructure(structure: StructureShape): RuntimeType {
TODO("AwsQuery doesn't support payload serialization")
}
override fun operationSerializer(operationShape: OperationShape): RuntimeType? {
val fnName = symbolProvider.serializeFunctionName(operationShape)
val inputShape = operationShape.inputShape(model)
return RuntimeType.forInlineFun(fnName, operationSerModule) { writer ->