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

package stacktrace

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

// DecodeMsg implements msgp.Decodable
func (z *Event) 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 "type":
			z.Type, err = dc.ReadString()
			if err != nil {
				err = msgp.WrapError(err, "Type")
				return
			}
		case "language":
			z.Language, err = dc.ReadString()
			if err != nil {
				err = msgp.WrapError(err, "Language")
				return
			}
		case "id":
			z.ID, err = dc.ReadString()
			if err != nil {
				err = msgp.WrapError(err, "ID")
				return
			}
		case "message":
			z.Message, err = dc.ReadString()
			if err != nil {
				err = msgp.WrapError(err, "Message")
				return
			}
		case "frames":
			err = z.Frames.DecodeMsg(dc)
			if err != nil {
				err = msgp.WrapError(err, "Frames")
				return
			}
		default:
			err = dc.Skip()
			if err != nil {
				err = msgp.WrapError(err)
				return
			}
		}
	}
	return
}

// EncodeMsg implements msgp.Encodable
func (z *Event) EncodeMsg(en *msgp.Writer) (err error) {
	// check for omitted fields
	zb0001Len := uint32(5)
	var zb0001Mask uint8 /* 5 bits */
	_ = zb0001Mask
	if z.Type == "" {
		zb0001Len--
		zb0001Mask |= 0x1
	}
	if z.Language == "" {
		zb0001Len--
		zb0001Mask |= 0x2
	}
	if z.ID == "" {
		zb0001Len--
		zb0001Mask |= 0x4
	}
	if z.Message == "" {
		zb0001Len--
		zb0001Mask |= 0x8
	}
	// variable map header, size zb0001Len
	err = en.Append(0x80 | uint8(zb0001Len))
	if err != nil {
		return
	}

	// skip if no fields are to be emitted
	if zb0001Len != 0 {
		if (zb0001Mask & 0x1) == 0 { // if not omitted
			// write "type"
			err = en.Append(0xa4, 0x74, 0x79, 0x70, 0x65)
			if err != nil {
				return
			}
			err = en.WriteString(z.Type)
			if err != nil {
				err = msgp.WrapError(err, "Type")
				return
			}
		}
		if (zb0001Mask & 0x2) == 0 { // if not omitted
			// write "language"
			err = en.Append(0xa8, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65)
			if err != nil {
				return
			}
			err = en.WriteString(z.Language)
			if err != nil {
				err = msgp.WrapError(err, "Language")
				return
			}
		}
		if (zb0001Mask & 0x4) == 0 { // if not omitted
			// write "id"
			err = en.Append(0xa2, 0x69, 0x64)
			if err != nil {
				return
			}
			err = en.WriteString(z.ID)
			if err != nil {
				err = msgp.WrapError(err, "ID")
				return
			}
		}
		if (zb0001Mask & 0x8) == 0 { // if not omitted
			// write "message"
			err = en.Append(0xa7, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65)
			if err != nil {
				return
			}
			err = en.WriteString(z.Message)
			if err != nil {
				err = msgp.WrapError(err, "Message")
				return
			}
		}
		// write "frames"
		err = en.Append(0xa6, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x73)
		if err != nil {
			return
		}
		err = z.Frames.EncodeMsg(en)
		if err != nil {
			err = msgp.WrapError(err, "Frames")
			return
		}
	}
	return
}

// MarshalMsg implements msgp.Marshaler
func (z *Event) MarshalMsg(b []byte) (o []byte, err error) {
	o = msgp.Require(b, z.Msgsize())
	// check for omitted fields
	zb0001Len := uint32(5)
	var zb0001Mask uint8 /* 5 bits */
	_ = zb0001Mask
	if z.Type == "" {
		zb0001Len--
		zb0001Mask |= 0x1
	}
	if z.Language == "" {
		zb0001Len--
		zb0001Mask |= 0x2
	}
	if z.ID == "" {
		zb0001Len--
		zb0001Mask |= 0x4
	}
	if z.Message == "" {
		zb0001Len--
		zb0001Mask |= 0x8
	}
	// variable map header, size zb0001Len
	o = append(o, 0x80|uint8(zb0001Len))

	// skip if no fields are to be emitted
	if zb0001Len != 0 {
		if (zb0001Mask & 0x1) == 0 { // if not omitted
			// string "type"
			o = append(o, 0xa4, 0x74, 0x79, 0x70, 0x65)
			o = msgp.AppendString(o, z.Type)
		}
		if (zb0001Mask & 0x2) == 0 { // if not omitted
			// string "language"
			o = append(o, 0xa8, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65)
			o = msgp.AppendString(o, z.Language)
		}
		if (zb0001Mask & 0x4) == 0 { // if not omitted
			// string "id"
			o = append(o, 0xa2, 0x69, 0x64)
			o = msgp.AppendString(o, z.ID)
		}
		if (zb0001Mask & 0x8) == 0 { // if not omitted
			// string "message"
			o = append(o, 0xa7, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65)
			o = msgp.AppendString(o, z.Message)
		}
		// string "frames"
		o = append(o, 0xa6, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x73)
		o, err = z.Frames.MarshalMsg(o)
		if err != nil {
			err = msgp.WrapError(err, "Frames")
			return
		}
	}
	return
}

// UnmarshalMsg implements msgp.Unmarshaler
func (z *Event) 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 "type":
			z.Type, bts, err = msgp.ReadStringBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "Type")
				return
			}
		case "language":
			z.Language, bts, err = msgp.ReadStringBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "Language")
				return
			}
		case "id":
			z.ID, bts, err = msgp.ReadStringBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "ID")
				return
			}
		case "message":
			z.Message, bts, err = msgp.ReadStringBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "Message")
				return
			}
		case "frames":
			bts, err = z.Frames.UnmarshalMsg(bts)
			if err != nil {
				err = msgp.WrapError(err, "Frames")
				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 *Event) Msgsize() (s int) {
	s = 1 + 5 + msgp.StringPrefixSize + len(z.Type) + 9 + msgp.StringPrefixSize + len(z.Language) + 3 + msgp.StringPrefixSize + len(z.ID) + 8 + msgp.StringPrefixSize + len(z.Message) + 7 + z.Frames.Msgsize()
	return
}

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

// EncodeMsg implements msgp.Encodable
func (z EventCategory) EncodeMsg(en *msgp.Writer) (err error) {
	err = en.WriteString(string(z))
	if err != nil {
		err = msgp.WrapError(err)
		return
	}
	return
}

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

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

// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z EventCategory) Msgsize() (s int) {
	s = msgp.StringPrefixSize + len(string(z))
	return
}
