package madmin

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

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

// DecodeMsg implements msgp.Decodable
func (z *ServiceTelemetryOpts) 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 "Types":
			{
				var zb0002 uint64
				zb0002, err = dc.ReadUint64()
				if err != nil {
					err = msgp.WrapError(err, "Types")
					return
				}
				z.Types = TraceType(zb0002)
			}
		case "PubCert":
			z.PubCert, err = dc.ReadBytes(z.PubCert)
			if err != nil {
				err = msgp.WrapError(err, "PubCert")
				return
			}
		case "SampleRate":
			z.SampleRate, err = dc.ReadFloat64()
			if err != nil {
				err = msgp.WrapError(err, "SampleRate")
				return
			}
		case "ParentOnly":
			z.ParentOnly, err = dc.ReadBool()
			if err != nil {
				err = msgp.WrapError(err, "ParentOnly")
				return
			}
		case "TagKV":
			var zb0003 uint32
			zb0003, err = dc.ReadMapHeader()
			if err != nil {
				err = msgp.WrapError(err, "TagKV")
				return
			}
			if z.TagKV == nil {
				z.TagKV = make(map[string]string, zb0003)
			} else if len(z.TagKV) > 0 {
				for key := range z.TagKV {
					delete(z.TagKV, key)
				}
			}
			for zb0003 > 0 {
				zb0003--
				var za0001 string
				var za0002 string
				za0001, err = dc.ReadString()
				if err != nil {
					err = msgp.WrapError(err, "TagKV")
					return
				}
				za0002, err = dc.ReadString()
				if err != nil {
					err = msgp.WrapError(err, "TagKV", za0001)
					return
				}
				z.TagKV[za0001] = za0002
			}
		case "HTTPFilter":
			var zb0004 uint32
			zb0004, err = dc.ReadMapHeader()
			if err != nil {
				err = msgp.WrapError(err, "HTTPFilter")
				return
			}
			for zb0004 > 0 {
				zb0004--
				field, err = dc.ReadMapKeyPtr()
				if err != nil {
					err = msgp.WrapError(err, "HTTPFilter")
					return
				}
				switch msgp.UnsafeString(field) {
				case "Func":
					z.HTTPFilter.Func, err = dc.ReadString()
					if err != nil {
						err = msgp.WrapError(err, "HTTPFilter", "Func")
						return
					}
				case "UserAgent":
					z.HTTPFilter.UserAgent, err = dc.ReadString()
					if err != nil {
						err = msgp.WrapError(err, "HTTPFilter", "UserAgent")
						return
					}
				case "Header":
					var zb0005 uint32
					zb0005, err = dc.ReadMapHeader()
					if err != nil {
						err = msgp.WrapError(err, "HTTPFilter", "Header")
						return
					}
					if z.HTTPFilter.Header == nil {
						z.HTTPFilter.Header = make(map[string]string, zb0005)
					} else if len(z.HTTPFilter.Header) > 0 {
						for key := range z.HTTPFilter.Header {
							delete(z.HTTPFilter.Header, key)
						}
					}
					for zb0005 > 0 {
						zb0005--
						var za0003 string
						var za0004 string
						za0003, err = dc.ReadString()
						if err != nil {
							err = msgp.WrapError(err, "HTTPFilter", "Header")
							return
						}
						za0004, err = dc.ReadString()
						if err != nil {
							err = msgp.WrapError(err, "HTTPFilter", "Header", za0003)
							return
						}
						z.HTTPFilter.Header[za0003] = za0004
					}
				default:
					err = dc.Skip()
					if err != nil {
						err = msgp.WrapError(err, "HTTPFilter")
						return
					}
				}
			}
		default:
			err = dc.Skip()
			if err != nil {
				err = msgp.WrapError(err)
				return
			}
		}
	}
	return
}

// EncodeMsg implements msgp.Encodable
func (z *ServiceTelemetryOpts) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 6
	// write "Types"
	err = en.Append(0x86, 0xa5, 0x54, 0x79, 0x70, 0x65, 0x73)
	if err != nil {
		return
	}
	err = en.WriteUint64(uint64(z.Types))
	if err != nil {
		err = msgp.WrapError(err, "Types")
		return
	}
	// write "PubCert"
	err = en.Append(0xa7, 0x50, 0x75, 0x62, 0x43, 0x65, 0x72, 0x74)
	if err != nil {
		return
	}
	err = en.WriteBytes(z.PubCert)
	if err != nil {
		err = msgp.WrapError(err, "PubCert")
		return
	}
	// write "SampleRate"
	err = en.Append(0xaa, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x61, 0x74, 0x65)
	if err != nil {
		return
	}
	err = en.WriteFloat64(z.SampleRate)
	if err != nil {
		err = msgp.WrapError(err, "SampleRate")
		return
	}
	// write "ParentOnly"
	err = en.Append(0xaa, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x4f, 0x6e, 0x6c, 0x79)
	if err != nil {
		return
	}
	err = en.WriteBool(z.ParentOnly)
	if err != nil {
		err = msgp.WrapError(err, "ParentOnly")
		return
	}
	// write "TagKV"
	err = en.Append(0xa5, 0x54, 0x61, 0x67, 0x4b, 0x56)
	if err != nil {
		return
	}
	err = en.WriteMapHeader(uint32(len(z.TagKV)))
	if err != nil {
		err = msgp.WrapError(err, "TagKV")
		return
	}
	for za0001, za0002 := range z.TagKV {
		err = en.WriteString(za0001)
		if err != nil {
			err = msgp.WrapError(err, "TagKV")
			return
		}
		err = en.WriteString(za0002)
		if err != nil {
			err = msgp.WrapError(err, "TagKV", za0001)
			return
		}
	}
	// write "HTTPFilter"
	err = en.Append(0xaa, 0x48, 0x54, 0x54, 0x50, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72)
	if err != nil {
		return
	}
	// map header, size 3
	// write "Func"
	err = en.Append(0x83, 0xa4, 0x46, 0x75, 0x6e, 0x63)
	if err != nil {
		return
	}
	err = en.WriteString(z.HTTPFilter.Func)
	if err != nil {
		err = msgp.WrapError(err, "HTTPFilter", "Func")
		return
	}
	// write "UserAgent"
	err = en.Append(0xa9, 0x55, 0x73, 0x65, 0x72, 0x41, 0x67, 0x65, 0x6e, 0x74)
	if err != nil {
		return
	}
	err = en.WriteString(z.HTTPFilter.UserAgent)
	if err != nil {
		err = msgp.WrapError(err, "HTTPFilter", "UserAgent")
		return
	}
	// write "Header"
	err = en.Append(0xa6, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72)
	if err != nil {
		return
	}
	err = en.WriteMapHeader(uint32(len(z.HTTPFilter.Header)))
	if err != nil {
		err = msgp.WrapError(err, "HTTPFilter", "Header")
		return
	}
	for za0003, za0004 := range z.HTTPFilter.Header {
		err = en.WriteString(za0003)
		if err != nil {
			err = msgp.WrapError(err, "HTTPFilter", "Header")
			return
		}
		err = en.WriteString(za0004)
		if err != nil {
			err = msgp.WrapError(err, "HTTPFilter", "Header", za0003)
			return
		}
	}
	return
}

// MarshalMsg implements msgp.Marshaler
func (z *ServiceTelemetryOpts) MarshalMsg(b []byte) (o []byte, err error) {
	o = msgp.Require(b, z.Msgsize())
	// map header, size 6
	// string "Types"
	o = append(o, 0x86, 0xa5, 0x54, 0x79, 0x70, 0x65, 0x73)
	o = msgp.AppendUint64(o, uint64(z.Types))
	// string "PubCert"
	o = append(o, 0xa7, 0x50, 0x75, 0x62, 0x43, 0x65, 0x72, 0x74)
	o = msgp.AppendBytes(o, z.PubCert)
	// string "SampleRate"
	o = append(o, 0xaa, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x61, 0x74, 0x65)
	o = msgp.AppendFloat64(o, z.SampleRate)
	// string "ParentOnly"
	o = append(o, 0xaa, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x4f, 0x6e, 0x6c, 0x79)
	o = msgp.AppendBool(o, z.ParentOnly)
	// string "TagKV"
	o = append(o, 0xa5, 0x54, 0x61, 0x67, 0x4b, 0x56)
	o = msgp.AppendMapHeader(o, uint32(len(z.TagKV)))
	for za0001, za0002 := range z.TagKV {
		o = msgp.AppendString(o, za0001)
		o = msgp.AppendString(o, za0002)
	}
	// string "HTTPFilter"
	o = append(o, 0xaa, 0x48, 0x54, 0x54, 0x50, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72)
	// map header, size 3
	// string "Func"
	o = append(o, 0x83, 0xa4, 0x46, 0x75, 0x6e, 0x63)
	o = msgp.AppendString(o, z.HTTPFilter.Func)
	// string "UserAgent"
	o = append(o, 0xa9, 0x55, 0x73, 0x65, 0x72, 0x41, 0x67, 0x65, 0x6e, 0x74)
	o = msgp.AppendString(o, z.HTTPFilter.UserAgent)
	// string "Header"
	o = append(o, 0xa6, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72)
	o = msgp.AppendMapHeader(o, uint32(len(z.HTTPFilter.Header)))
	for za0003, za0004 := range z.HTTPFilter.Header {
		o = msgp.AppendString(o, za0003)
		o = msgp.AppendString(o, za0004)
	}
	return
}

// UnmarshalMsg implements msgp.Unmarshaler
func (z *ServiceTelemetryOpts) 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 "Types":
			{
				var zb0002 uint64
				zb0002, bts, err = msgp.ReadUint64Bytes(bts)
				if err != nil {
					err = msgp.WrapError(err, "Types")
					return
				}
				z.Types = TraceType(zb0002)
			}
		case "PubCert":
			z.PubCert, bts, err = msgp.ReadBytesBytes(bts, z.PubCert)
			if err != nil {
				err = msgp.WrapError(err, "PubCert")
				return
			}
		case "SampleRate":
			z.SampleRate, bts, err = msgp.ReadFloat64Bytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "SampleRate")
				return
			}
		case "ParentOnly":
			z.ParentOnly, bts, err = msgp.ReadBoolBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "ParentOnly")
				return
			}
		case "TagKV":
			var zb0003 uint32
			zb0003, bts, err = msgp.ReadMapHeaderBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "TagKV")
				return
			}
			if z.TagKV == nil {
				z.TagKV = make(map[string]string, zb0003)
			} else if len(z.TagKV) > 0 {
				for key := range z.TagKV {
					delete(z.TagKV, key)
				}
			}
			for zb0003 > 0 {
				var za0001 string
				var za0002 string
				zb0003--
				za0001, bts, err = msgp.ReadStringBytes(bts)
				if err != nil {
					err = msgp.WrapError(err, "TagKV")
					return
				}
				za0002, bts, err = msgp.ReadStringBytes(bts)
				if err != nil {
					err = msgp.WrapError(err, "TagKV", za0001)
					return
				}
				z.TagKV[za0001] = za0002
			}
		case "HTTPFilter":
			var zb0004 uint32
			zb0004, bts, err = msgp.ReadMapHeaderBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "HTTPFilter")
				return
			}
			for zb0004 > 0 {
				zb0004--
				field, bts, err = msgp.ReadMapKeyZC(bts)
				if err != nil {
					err = msgp.WrapError(err, "HTTPFilter")
					return
				}
				switch msgp.UnsafeString(field) {
				case "Func":
					z.HTTPFilter.Func, bts, err = msgp.ReadStringBytes(bts)
					if err != nil {
						err = msgp.WrapError(err, "HTTPFilter", "Func")
						return
					}
				case "UserAgent":
					z.HTTPFilter.UserAgent, bts, err = msgp.ReadStringBytes(bts)
					if err != nil {
						err = msgp.WrapError(err, "HTTPFilter", "UserAgent")
						return
					}
				case "Header":
					var zb0005 uint32
					zb0005, bts, err = msgp.ReadMapHeaderBytes(bts)
					if err != nil {
						err = msgp.WrapError(err, "HTTPFilter", "Header")
						return
					}
					if z.HTTPFilter.Header == nil {
						z.HTTPFilter.Header = make(map[string]string, zb0005)
					} else if len(z.HTTPFilter.Header) > 0 {
						for key := range z.HTTPFilter.Header {
							delete(z.HTTPFilter.Header, key)
						}
					}
					for zb0005 > 0 {
						var za0003 string
						var za0004 string
						zb0005--
						za0003, bts, err = msgp.ReadStringBytes(bts)
						if err != nil {
							err = msgp.WrapError(err, "HTTPFilter", "Header")
							return
						}
						za0004, bts, err = msgp.ReadStringBytes(bts)
						if err != nil {
							err = msgp.WrapError(err, "HTTPFilter", "Header", za0003)
							return
						}
						z.HTTPFilter.Header[za0003] = za0004
					}
				default:
					bts, err = msgp.Skip(bts)
					if err != nil {
						err = msgp.WrapError(err, "HTTPFilter")
						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 *ServiceTelemetryOpts) Msgsize() (s int) {
	s = 1 + 6 + msgp.Uint64Size + 8 + msgp.BytesPrefixSize + len(z.PubCert) + 11 + msgp.Float64Size + 11 + msgp.BoolSize + 6 + msgp.MapHeaderSize
	if z.TagKV != nil {
		for za0001, za0002 := range z.TagKV {
			_ = za0002
			s += msgp.StringPrefixSize + len(za0001) + msgp.StringPrefixSize + len(za0002)
		}
	}
	s += 11 + 1 + 5 + msgp.StringPrefixSize + len(z.HTTPFilter.Func) + 10 + msgp.StringPrefixSize + len(z.HTTPFilter.UserAgent) + 7 + msgp.MapHeaderSize
	if z.HTTPFilter.Header != nil {
		for za0003, za0004 := range z.HTTPFilter.Header {
			_ = za0004
			s += msgp.StringPrefixSize + len(za0003) + msgp.StringPrefixSize + len(za0004)
		}
	}
	return
}
