// Code generated by smithy-go-codegen DO NOT EDIT.

package jsonrpc10

import (
	"github.com/aws/aws-sdk-go-v2/internal/protocoltest/jsonrpc10/schemas"
	"github.com/aws/aws-sdk-go-v2/internal/protocoltest/jsonrpc10/types"
	smithy "github.com/aws/smithy-go"
)

func serializeMyUnion(s smithy.ShapeSerializer, schema *smithy.Schema, v types.MyUnion) {
	switch vv := v.(type) {
	case *types.MyUnionMemberBlobValue:
		s.WriteUnion(schema, schemas.MyUnion_blobValue)
		s.WriteBlob(schemas.MyUnion_blobValue, vv.Value)
		s.CloseUnion()
	case *types.MyUnionMemberBooleanValue:
		s.WriteUnion(schema, schemas.MyUnion_booleanValue)
		s.WriteBool(schemas.MyUnion_booleanValue, vv.Value)
		s.CloseUnion()
	case *types.MyUnionMemberEnumValue:
		s.WriteUnion(schema, schemas.MyUnion_enumValue)
		s.WriteString(schemas.MyUnion_enumValue, string(vv.Value))
		s.CloseUnion()
	case *types.MyUnionMemberIntEnumValue:
		s.WriteUnion(schema, schemas.MyUnion_intEnumValue)
		s.WriteInt32(schemas.MyUnion_intEnumValue, int32(vv.Value))
		s.CloseUnion()
	case *types.MyUnionMemberListValue:
		s.WriteUnion(schema, schemas.MyUnion_listValue)
		serializeStringList(s, schemas.MyUnion_listValue, vv.Value)
		s.CloseUnion()
	case *types.MyUnionMemberMapValue:
		s.WriteUnion(schema, schemas.MyUnion_mapValue)
		serializeStringMap(s, schemas.MyUnion_mapValue, vv.Value)
		s.CloseUnion()
	case *types.MyUnionMemberNumberValue:
		s.WriteUnion(schema, schemas.MyUnion_numberValue)
		s.WriteInt32(schemas.MyUnion_numberValue, vv.Value)
		s.CloseUnion()
	case *types.MyUnionMemberStringValue:
		s.WriteUnion(schema, schemas.MyUnion_stringValue)
		s.WriteString(schemas.MyUnion_stringValue, vv.Value)
		s.CloseUnion()
	case *types.MyUnionMemberStructureValue:
		s.WriteUnion(schema, schemas.MyUnion_structureValue)
		s.WriteStruct(schemas.MyUnion_structureValue)
		vv.Value.SerializeMembers(s)
		s.CloseStruct()
		s.CloseUnion()
	case *types.MyUnionMemberTimestampValue:
		s.WriteUnion(schema, schemas.MyUnion_timestampValue)
		s.WriteTime(schemas.MyUnion_timestampValue, vv.Value)
		s.CloseUnion()
	}
}

func deserializeMyUnion(d smithy.ShapeDeserializer, s *smithy.Schema, v *types.MyUnion) error {
	return smithy.ReadUnion(d, s, func(ms *smithy.Schema) error {
		switch ms {
		case schemas.MyUnion_blobValue:
			vv := &types.MyUnionMemberBlobValue{}
			*v = vv
			return vv.Deserialize(d)
		case schemas.MyUnion_booleanValue:
			vv := &types.MyUnionMemberBooleanValue{}
			*v = vv
			return vv.Deserialize(d)
		case schemas.MyUnion_enumValue:
			vv := &types.MyUnionMemberEnumValue{}
			*v = vv
			return vv.Deserialize(d)
		case schemas.MyUnion_intEnumValue:
			vv := &types.MyUnionMemberIntEnumValue{}
			*v = vv
			return vv.Deserialize(d)
		case schemas.MyUnion_listValue:
			vv := &types.MyUnionMemberListValue{}
			*v = vv
			return vv.Deserialize(d)
		case schemas.MyUnion_mapValue:
			vv := &types.MyUnionMemberMapValue{}
			*v = vv
			return vv.Deserialize(d)
		case schemas.MyUnion_numberValue:
			vv := &types.MyUnionMemberNumberValue{}
			*v = vv
			return vv.Deserialize(d)
		case schemas.MyUnion_stringValue:
			vv := &types.MyUnionMemberStringValue{}
			*v = vv
			return vv.Deserialize(d)
		case schemas.MyUnion_structureValue:
			vv := &types.MyUnionMemberStructureValue{}
			*v = vv
			return vv.Deserialize(d)
		case schemas.MyUnion_timestampValue:
			vv := &types.MyUnionMemberTimestampValue{}
			*v = vv
			return vv.Deserialize(d)
		}
		return nil
	})
}

func serializeDialogList(s smithy.ShapeSerializer, schema *smithy.Schema, v []types.Dialog) {
	if v == nil {
		return
	}
	s.WriteList(schema)
	for _, vv := range v {
		s.WriteStruct(schema.ListMember())
		vv.SerializeMembers(s)
		s.CloseStruct()
	}
	s.CloseList()
}

func serializeRequiredStringList(s smithy.ShapeSerializer, schema *smithy.Schema, v []string) {
	if v == nil {
		return
	}
	s.WriteList(schema)
	for _, vv := range v {
		s.WriteString(schema.ListMember(), string(vv))
	}
	s.CloseList()
}

func serializeTestStringList(s smithy.ShapeSerializer, schema *smithy.Schema, v []string) {
	if v == nil {
		return
	}
	s.WriteList(schema)
	for _, vv := range v {
		s.WriteString(schema.ListMember(), string(vv))
	}
	s.CloseList()
}

func serializeStringList(s smithy.ShapeSerializer, schema *smithy.Schema, v []string) {
	if v == nil {
		return
	}
	s.WriteList(schema)
	for _, vv := range v {
		s.WriteString(schema.ListMember(), string(vv))
	}
	s.CloseList()
}

func deserializeDialogList(d smithy.ShapeDeserializer, s *smithy.Schema, v *[]types.Dialog) error {
	var vv types.Dialog
	return smithy.ReadList(d, s, func() error {
		vv = types.Dialog{}
		if err := vv.Deserialize(d); err != nil {
			return err
		}

		*v = append(*v, vv)
		return nil
	})
}

func deserializeRequiredStringList(d smithy.ShapeDeserializer, s *smithy.Schema, v *[]string) error {
	var vv string
	return smithy.ReadList(d, s, func() error {

		if err := d.ReadString(s.ListMember(), &vv); err != nil {
			return err
		}

		*v = append(*v, vv)
		return nil
	})
}

func deserializeTestStringList(d smithy.ShapeDeserializer, s *smithy.Schema, v *[]string) error {
	var vv string
	return smithy.ReadList(d, s, func() error {

		if err := d.ReadString(s.ListMember(), &vv); err != nil {
			return err
		}

		*v = append(*v, vv)
		return nil
	})
}

func deserializeStringList(d smithy.ShapeDeserializer, s *smithy.Schema, v *[]string) error {
	var vv string
	return smithy.ReadList(d, s, func() error {

		if err := d.ReadString(s.ListMember(), &vv); err != nil {
			return err
		}

		*v = append(*v, vv)
		return nil
	})
}

func serializeDialogMap(s smithy.ShapeSerializer, schema *smithy.Schema, v map[string]types.Dialog) {
	if v == nil {
		return
	}
	s.WriteMap(schema)
	for k, vv := range v {
		s.WriteKey(schema.MapKey(), k)
		s.WriteStruct(schema.MapValue())
		vv.SerializeMembers(s)
		s.CloseStruct()
	}
	s.CloseMap()
}

func serializeRequiredStringMap(s smithy.ShapeSerializer, schema *smithy.Schema, v map[string]string) {
	if v == nil {
		return
	}
	s.WriteMap(schema)
	for k, vv := range v {
		s.WriteKey(schema.MapKey(), k)
		s.WriteString(schema.MapValue(), string(vv))
	}
	s.CloseMap()
}

func serializeTestStringMap(s smithy.ShapeSerializer, schema *smithy.Schema, v map[string]string) {
	if v == nil {
		return
	}
	s.WriteMap(schema)
	for k, vv := range v {
		s.WriteKey(schema.MapKey(), k)
		s.WriteString(schema.MapValue(), string(vv))
	}
	s.CloseMap()
}

func serializeStringMap(s smithy.ShapeSerializer, schema *smithy.Schema, v map[string]string) {
	if v == nil {
		return
	}
	s.WriteMap(schema)
	for k, vv := range v {
		s.WriteKey(schema.MapKey(), k)
		s.WriteString(schema.MapValue(), string(vv))
	}
	s.CloseMap()
}

func deserializeDialogMap(d smithy.ShapeDeserializer, s *smithy.Schema, v *map[string]types.Dialog) error {
	*v = make(map[string]types.Dialog)
	var vv types.Dialog
	return smithy.ReadMap(d, s, func(k string) error {
		vv = types.Dialog{}
		if err := vv.Deserialize(d); err != nil {
			return err
		}

		(*v)[k] = vv
		return nil
	})
}

func deserializeRequiredStringMap(d smithy.ShapeDeserializer, s *smithy.Schema, v *map[string]string) error {
	*v = make(map[string]string)
	var vv string
	return smithy.ReadMap(d, s, func(k string) error {

		if err := d.ReadString(s.MapValue(), &vv); err != nil {
			return err
		}

		(*v)[k] = vv
		return nil
	})
}

func deserializeTestStringMap(d smithy.ShapeDeserializer, s *smithy.Schema, v *map[string]string) error {
	*v = make(map[string]string)
	var vv string
	return smithy.ReadMap(d, s, func(k string) error {

		if err := d.ReadString(s.MapValue(), &vv); err != nil {
			return err
		}

		(*v)[k] = vv
		return nil
	})
}

func deserializeStringMap(d smithy.ShapeDeserializer, s *smithy.Schema, v *map[string]string) error {
	*v = make(map[string]string)
	var vv string
	return smithy.ReadMap(d, s, func(k string) error {

		if err := d.ReadString(s.MapValue(), &vv); err != nil {
			return err
		}

		(*v)[k] = vv
		return nil
	})
}
