Пример #1
0
// DecodeMsg implements msgp.Decodable
func (z *Subload) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var isz uint32
	isz, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for isz > 0 {
		isz--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "A":
			z.A, err = dc.ReadString()
			if err != nil {
				return
			}
		case "B":
			z.B, err = dc.ReadInt()
			if err != nil {
				return
			}
		case "F":
			var xsz uint32
			xsz, err = dc.ReadArrayHeader()
			if err != nil {
				return
			}
			if cap(z.F) >= int(xsz) {
				z.F = z.F[:xsz]
			} else {
				z.F = make([]float64, xsz)
			}
			for cmr := range z.F {
				z.F[cmr], err = dc.ReadFloat64()
				if err != nil {
					return
				}
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
Пример #2
0
// DecodeMsg implements msgp.Decodable
func (z *Payload) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var isz uint32
	isz, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for isz > 0 {
		isz--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "Sub":
			err = z.Sub.DecodeMsg(dc)
			if err != nil {
				return
			}
		case "D":
			var xsz uint32
			xsz, err = dc.ReadArrayHeader()
			if err != nil {
				return
			}
			if cap(z.D) >= int(xsz) {
				z.D = z.D[:xsz]
			} else {
				z.D = make([]string, xsz)
			}
			for xvk := range z.D {
				z.D[xvk], err = dc.ReadString()
				if err != nil {
					return
				}
			}
		case "E":
			var xsz uint32
			xsz, err = dc.ReadArrayHeader()
			if err != nil {
				return
			}
			if cap(z.E) >= int(xsz) {
				z.E = z.E[:xsz]
			} else {
				z.E = make([]int32, xsz)
			}
			for bzg := range z.E {
				z.E[bzg], err = dc.ReadInt32()
				if err != nil {
					return
				}
			}
		case "G":
			var xsz uint32
			xsz, err = dc.ReadArrayHeader()
			if err != nil {
				return
			}
			if cap(z.G) >= int(xsz) {
				z.G = z.G[:xsz]
			} else {
				z.G = make([]float64, xsz)
			}
			for bai := range z.G {
				z.G[bai], err = dc.ReadFloat64()
				if err != nil {
					return
				}
			}
		case "Blob":
			z.Blob, err = dc.ReadBytes(z.Blob)
			if err != nil {
				return
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}