package model

// Code generated by github.com/tinylib/msgp DO NOT EDIT.

import (
	"github.com/tinylib/msgp/msgp"
)

// DecodeMsg implements msgp.Decodable
func (z *OpType) DecodeMsg(dc *msgp.Reader) (err error) {
	{
		var zb0001 int
		zb0001, err = dc.ReadInt()
		if err != nil {
			err = msgp.WrapError(err)
			return
		}
		(*z) = OpType(zb0001)
	}
	return
}

// EncodeMsg implements msgp.Encodable
func (z OpType) EncodeMsg(en *msgp.Writer) (err error) {
	err = en.WriteInt(int(z))
	if err != nil {
		err = msgp.WrapError(err)
		return
	}
	return
}

// MarshalMsg implements msgp.Marshaler
func (z OpType) MarshalMsg(b []byte) (o []byte, err error) {
	o = msgp.Require(b, z.Msgsize())
	o = msgp.AppendInt(o, int(z))
	return
}

// UnmarshalMsg implements msgp.Unmarshaler
func (z *OpType) UnmarshalMsg(bts []byte) (o []byte, err error) {
	{
		var zb0001 int
		zb0001, bts, err = msgp.ReadIntBytes(bts)
		if err != nil {
			err = msgp.WrapError(err)
			return
		}
		(*z) = OpType(zb0001)
	}
	o = bts
	return
}

// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z OpType) Msgsize() (s int) {
	s = msgp.IntSize
	return
}

// DecodeMsg implements msgp.Decodable
func (z *RawKVEntry) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var zb0001 uint32
	zb0001, err = dc.ReadMapHeader()
	if err != nil {
		err = msgp.WrapError(err)
		return
	}
	for zb0001 > 0 {
		zb0001--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			err = msgp.WrapError(err)
			return
		}
		switch msgp.UnsafeString(field) {
		case "op_type":
			{
				var zb0002 int
				zb0002, err = dc.ReadInt()
				if err != nil {
					err = msgp.WrapError(err, "OpType")
					return
				}
				z.OpType = OpType(zb0002)
			}
		case "key":
			z.Key, err = dc.ReadBytes(z.Key)
			if err != nil {
				err = msgp.WrapError(err, "Key")
				return
			}
		case "value":
			z.Value, err = dc.ReadBytes(z.Value)
			if err != nil {
				err = msgp.WrapError(err, "Value")
				return
			}
		case "old_value":
			z.OldValue, err = dc.ReadBytes(z.OldValue)
			if err != nil {
				err = msgp.WrapError(err, "OldValue")
				return
			}
		case "start_ts":
			z.StartTs, err = dc.ReadUint64()
			if err != nil {
				err = msgp.WrapError(err, "StartTs")
				return
			}
		case "crts":
			z.CRTs, err = dc.ReadUint64()
			if err != nil {
				err = msgp.WrapError(err, "CRTs")
				return
			}
		case "region_id":
			z.RegionID, err = dc.ReadUint64()
			if err != nil {
				err = msgp.WrapError(err, "RegionID")
				return
			}
		default:
			err = dc.Skip()
			if err != nil {
				err = msgp.WrapError(err)
				return
			}
		}
	}
	return
}

// EncodeMsg implements msgp.Encodable
func (z *RawKVEntry) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 7
	// write "op_type"
	err = en.Append(0x87, 0xa7, 0x6f, 0x70, 0x5f, 0x74, 0x79, 0x70, 0x65)
	if err != nil {
		return
	}
	err = en.WriteInt(int(z.OpType))
	if err != nil {
		err = msgp.WrapError(err, "OpType")
		return
	}
	// write "key"
	err = en.Append(0xa3, 0x6b, 0x65, 0x79)
	if err != nil {
		return
	}
	err = en.WriteBytes(z.Key)
	if err != nil {
		err = msgp.WrapError(err, "Key")
		return
	}
	// write "value"
	err = en.Append(0xa5, 0x76, 0x61, 0x6c, 0x75, 0x65)
	if err != nil {
		return
	}
	err = en.WriteBytes(z.Value)
	if err != nil {
		err = msgp.WrapError(err, "Value")
		return
	}
	// write "old_value"
	err = en.Append(0xa9, 0x6f, 0x6c, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65)
	if err != nil {
		return
	}
	err = en.WriteBytes(z.OldValue)
	if err != nil {
		err = msgp.WrapError(err, "OldValue")
		return
	}
	// write "start_ts"
	err = en.Append(0xa8, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x73)
	if err != nil {
		return
	}
	err = en.WriteUint64(z.StartTs)
	if err != nil {
		err = msgp.WrapError(err, "StartTs")
		return
	}
	// write "crts"
	err = en.Append(0xa4, 0x63, 0x72, 0x74, 0x73)
	if err != nil {
		return
	}
	err = en.WriteUint64(z.CRTs)
	if err != nil {
		err = msgp.WrapError(err, "CRTs")
		return
	}
	// write "region_id"
	err = en.Append(0xa9, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64)
	if err != nil {
		return
	}
	err = en.WriteUint64(z.RegionID)
	if err != nil {
		err = msgp.WrapError(err, "RegionID")
		return
	}
	return
}

// MarshalMsg implements msgp.Marshaler
func (z *RawKVEntry) MarshalMsg(b []byte) (o []byte, err error) {
	o = msgp.Require(b, z.Msgsize())
	// map header, size 7
	// string "op_type"
	o = append(o, 0x87, 0xa7, 0x6f, 0x70, 0x5f, 0x74, 0x79, 0x70, 0x65)
	o = msgp.AppendInt(o, int(z.OpType))
	// string "key"
	o = append(o, 0xa3, 0x6b, 0x65, 0x79)
	o = msgp.AppendBytes(o, z.Key)
	// string "value"
	o = append(o, 0xa5, 0x76, 0x61, 0x6c, 0x75, 0x65)
	o = msgp.AppendBytes(o, z.Value)
	// string "old_value"
	o = append(o, 0xa9, 0x6f, 0x6c, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65)
	o = msgp.AppendBytes(o, z.OldValue)
	// string "start_ts"
	o = append(o, 0xa8, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x73)
	o = msgp.AppendUint64(o, z.StartTs)
	// string "crts"
	o = append(o, 0xa4, 0x63, 0x72, 0x74, 0x73)
	o = msgp.AppendUint64(o, z.CRTs)
	// string "region_id"
	o = append(o, 0xa9, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64)
	o = msgp.AppendUint64(o, z.RegionID)
	return
}

// UnmarshalMsg implements msgp.Unmarshaler
func (z *RawKVEntry) UnmarshalMsg(bts []byte) (o []byte, err error) {
	var field []byte
	_ = field
	var zb0001 uint32
	zb0001, bts, err = msgp.ReadMapHeaderBytes(bts)
	if err != nil {
		err = msgp.WrapError(err)
		return
	}
	for zb0001 > 0 {
		zb0001--
		field, bts, err = msgp.ReadMapKeyZC(bts)
		if err != nil {
			err = msgp.WrapError(err)
			return
		}
		switch msgp.UnsafeString(field) {
		case "op_type":
			{
				var zb0002 int
				zb0002, bts, err = msgp.ReadIntBytes(bts)
				if err != nil {
					err = msgp.WrapError(err, "OpType")
					return
				}
				z.OpType = OpType(zb0002)
			}
		case "key":
			z.Key, bts, err = msgp.ReadBytesBytes(bts, z.Key)
			if err != nil {
				err = msgp.WrapError(err, "Key")
				return
			}
		case "value":
			z.Value, bts, err = msgp.ReadBytesBytes(bts, z.Value)
			if err != nil {
				err = msgp.WrapError(err, "Value")
				return
			}
		case "old_value":
			z.OldValue, bts, err = msgp.ReadBytesBytes(bts, z.OldValue)
			if err != nil {
				err = msgp.WrapError(err, "OldValue")
				return
			}
		case "start_ts":
			z.StartTs, bts, err = msgp.ReadUint64Bytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "StartTs")
				return
			}
		case "crts":
			z.CRTs, bts, err = msgp.ReadUint64Bytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "CRTs")
				return
			}
		case "region_id":
			z.RegionID, bts, err = msgp.ReadUint64Bytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "RegionID")
				return
			}
		default:
			bts, err = msgp.Skip(bts)
			if err != nil {
				err = msgp.WrapError(err)
				return
			}
		}
	}
	o = bts
	return
}

// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *RawKVEntry) Msgsize() (s int) {
	s = 1 + 8 + msgp.IntSize + 4 + msgp.BytesPrefixSize + len(z.Key) + 6 + msgp.BytesPrefixSize + len(z.Value) + 10 + msgp.BytesPrefixSize + len(z.OldValue) + 9 + msgp.Uint64Size + 5 + msgp.Uint64Size + 10 + msgp.Uint64Size
	return
}
