Beispiel #1
0
// UnmarshalMsg unmarshals a MsgPackSample from MessagePack, returning any extra bytes
// and any errors encountered
func (z *MsgPackSample) UnmarshalMsg(bts []byte) (o []byte, err error) {
	var field []byte
	_ = field

	var isz uint32
	isz, bts, err = msgp.ReadMapHeaderBytes(bts)
	if err != nil {
		return
	}
	for xplz := uint32(0); xplz < isz; xplz++ {
		field, bts, err = msgp.ReadMapKeyZC(bts)
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {

		case "Name":

			z.Name, bts, err = msgp.ReadStringBytes(bts)

			if err != nil {
				return
			}

		case "Num":

			z.Num, bts, err = msgp.ReadIntBytes(bts)

			if err != nil {
				return
			}

		case "Message":

			z.Message, bts, err = msgp.ReadStringBytes(bts)

			if err != nil {
				return
			}

		default:
			bts, err = msgp.Skip(bts)
			if err != nil {
				return
			}
		}
	}

	o = bts
	return
}
Beispiel #2
0
// DecodeMsg implements the msgp.Decodable interface
func (z *MsgPackSample) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field

	var isz uint32
	isz, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for xplz := uint32(0); xplz < isz; xplz++ {
		field, err = dc.ReadMapKey(field)
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {

		case "Name":

			z.Name, err = dc.ReadString()

			if err != nil {
				return
			}

		case "Num":

			z.Num, err = dc.ReadInt()

			if err != nil {
				return
			}

		case "Message":

			z.Message, err = dc.ReadString()

			if err != nil {
				return
			}

		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}

	return
}
// UnmarshalMsg unmarshals a A from MessagePack, returning any extra bytes
// and any errors encountered
func (z *A) UnmarshalMsg(bts []byte) (o []byte, err error) {
	var field []byte
	_ = field

	var isz uint32
	isz, bts, err = msgp.ReadMapHeaderBytes(bts)
	if err != nil {
		return
	}
	for xplz := uint32(0); xplz < isz; xplz++ {
		field, bts, err = msgp.ReadMapKeyZC(bts)
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {

		case "Name":

			z.Name, bts, err = msgp.ReadStringBytes(bts)

			if err != nil {
				return
			}

		case "BirthDay":

			z.BirthDay, bts, err = msgp.ReadTimeBytes(bts)

			if err != nil {
				return
			}

		case "Phone":

			z.Phone, bts, err = msgp.ReadStringBytes(bts)

			if err != nil {
				return
			}

		case "Siblings":

			z.Siblings, bts, err = msgp.ReadIntBytes(bts)

			if err != nil {
				return
			}

		case "Spouse":

			z.Spouse, bts, err = msgp.ReadBoolBytes(bts)

			if err != nil {
				return
			}

		case "Money":

			z.Money, bts, err = msgp.ReadFloat64Bytes(bts)

			if err != nil {
				return
			}

		default:
			bts, err = msgp.Skip(bts)
			if err != nil {
				return
			}
		}
	}

	o = bts
	return
}