Ejemplo n.º 1
0
// DecodeMsg implements msgp.Decodable
func (z *interval32) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var zeff uint32
	zeff, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for zeff > 0 {
		zeff--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "start":
			z.start, err = dc.ReadUint32()
			if err != nil {
				return
			}
		case "last":
			z.last, err = dc.ReadUint32()
			if err != nil {
				return
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
Ejemplo n.º 2
0
func (r *Request) DecodeMsg(mr *msgp.Reader) error {
	var bm msgp.Decodable

	if r.Body != nil {
		var ok bool
		bm, ok = r.Body.(msgp.Decodable)
		if !ok {
			return ErrNotDecodable
		}
	}

	if size, err := mr.ReadArrayHeader(); err != nil {
		return err
	} else if size != RequestPackSize {
		return ErrBadPackSize
	}

	if typ, err := mr.ReadInt(); err != nil {
		return err
	} else if typ != RequestType {
		return ErrBadMessageType
	}

	id, err := mr.ReadUint32()
	if err != nil {
		return err
	}

	r.ID = id

	method, err := mr.ReadString()
	if err != nil {
		return err
	}

	r.Method = method

	// The request body is packed in an array.
	l, err := mr.ReadArrayHeader()
	if err != nil {
		return err
	}

	if l > 1 {
		return ErrUnexpectedParams
	} else if l == 0 {
		return nil
	}

	r.hasBody = true

	// Skip decoding the body if no value is present to decode into.
	// The caller is expected to decode the body or skip it.
	if bm != nil {
		return decodeBody(mr, bm)
	}

	return nil
}
Ejemplo n.º 3
0
// DecodeMsg implements msgp.Decodable
func (z *runIterator32) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var zqke uint32
	zqke, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for zqke > 0 {
		zqke--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "rc":
			if dc.IsNil() {
				err = dc.ReadNil()
				if err != nil {
					return
				}
				z.rc = nil
			} else {
				if z.rc == nil {
					z.rc = new(runContainer32)
				}
				err = z.rc.DecodeMsg(dc)
				if err != nil {
					return
				}
			}
		case "curIndex":
			z.curIndex, err = dc.ReadInt64()
			if err != nil {
				return
			}
		case "curPosInIndex":
			z.curPosInIndex, err = dc.ReadUint32()
			if err != nil {
				return
			}
		case "curSeq":
			z.curSeq, err = dc.ReadInt64()
			if err != nil {
				return
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
Ejemplo n.º 4
0
// DecodeMsg implements msgp.Decodable
func (z *uint32Slice) DecodeMsg(dc *msgp.Reader) (err error) {
	var zjpj uint32
	zjpj, err = dc.ReadArrayHeader()
	if err != nil {
		return
	}
	if cap((*z)) >= int(zjpj) {
		(*z) = (*z)[:zjpj]
	} else {
		(*z) = make(uint32Slice, zjpj)
	}
	for zywj := range *z {
		(*z)[zywj], err = dc.ReadUint32()
		if err != nil {
			return
		}
	}
	return
}
Ejemplo n.º 5
0
// DecodeMsg implements msgp.Decodable
func (z *Outgoing) 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 "time":
			z.Time, err = dc.ReadUint32()
			if err != nil {
				return
			}
		case "from":
			z.From, err = dc.ReadString()
			if err != nil {
				return
			}
		case "message":
			z.Message, err = dc.ReadString()
			if err != nil {
				return
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
Ejemplo n.º 6
0
// DecodeMsg implements msgp.Decodable
func (z *addHelper32) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var zbai uint32
	zbai, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for zbai > 0 {
		zbai--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "runstart":
			z.runstart, err = dc.ReadUint32()
			if err != nil {
				return
			}
		case "runlen":
			z.runlen, err = dc.ReadUint32()
			if err != nil {
				return
			}
		case "actuallyAdded":
			z.actuallyAdded, err = dc.ReadUint32()
			if err != nil {
				return
			}
		case "m":
			var zcmr uint32
			zcmr, err = dc.ReadArrayHeader()
			if err != nil {
				return
			}
			if cap(z.m) >= int(zcmr) {
				z.m = (z.m)[:zcmr]
			} else {
				z.m = make([]interval32, zcmr)
			}
			for zxvk := range z.m {
				var zajw uint32
				zajw, err = dc.ReadMapHeader()
				if err != nil {
					return
				}
				for zajw > 0 {
					zajw--
					field, err = dc.ReadMapKeyPtr()
					if err != nil {
						return
					}
					switch msgp.UnsafeString(field) {
					case "start":
						z.m[zxvk].start, err = dc.ReadUint32()
						if err != nil {
							return
						}
					case "last":
						z.m[zxvk].last, err = dc.ReadUint32()
						if err != nil {
							return
						}
					default:
						err = dc.Skip()
						if err != nil {
							return
						}
					}
				}
			}
		case "rc":
			if dc.IsNil() {
				err = dc.ReadNil()
				if err != nil {
					return
				}
				z.rc = nil
			} else {
				if z.rc == nil {
					z.rc = new(runContainer32)
				}
				var zwht uint32
				zwht, err = dc.ReadMapHeader()
				if err != nil {
					return
				}
				for zwht > 0 {
					zwht--
					field, err = dc.ReadMapKeyPtr()
					if err != nil {
						return
					}
					switch msgp.UnsafeString(field) {
					case "iv":
						var zhct uint32
						zhct, err = dc.ReadArrayHeader()
						if err != nil {
							return
						}
						if cap(z.rc.iv) >= int(zhct) {
							z.rc.iv = (z.rc.iv)[:zhct]
						} else {
							z.rc.iv = make([]interval32, zhct)
						}
						for zbzg := range z.rc.iv {
							var zcua uint32
							zcua, err = dc.ReadMapHeader()
							if err != nil {
								return
							}
							for zcua > 0 {
								zcua--
								field, err = dc.ReadMapKeyPtr()
								if err != nil {
									return
								}
								switch msgp.UnsafeString(field) {
								case "start":
									z.rc.iv[zbzg].start, err = dc.ReadUint32()
									if err != nil {
										return
									}
								case "last":
									z.rc.iv[zbzg].last, err = dc.ReadUint32()
									if err != nil {
										return
									}
								default:
									err = dc.Skip()
									if err != nil {
										return
									}
								}
							}
						}
					case "card":
						z.rc.card, err = dc.ReadInt64()
						if err != nil {
							return
						}
					default:
						err = dc.Skip()
						if err != nil {
							return
						}
					}
				}
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
Ejemplo n.º 7
0
// DecodeMsg implements msgp.Decodable
func (z *runContainer32) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var zdnj uint32
	zdnj, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for zdnj > 0 {
		zdnj--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "iv":
			var zobc uint32
			zobc, err = dc.ReadArrayHeader()
			if err != nil {
				return
			}
			if cap(z.iv) >= int(zobc) {
				z.iv = (z.iv)[:zobc]
			} else {
				z.iv = make([]interval32, zobc)
			}
			for zxpk := range z.iv {
				var zsnv uint32
				zsnv, err = dc.ReadMapHeader()
				if err != nil {
					return
				}
				for zsnv > 0 {
					zsnv--
					field, err = dc.ReadMapKeyPtr()
					if err != nil {
						return
					}
					switch msgp.UnsafeString(field) {
					case "start":
						z.iv[zxpk].start, err = dc.ReadUint32()
						if err != nil {
							return
						}
					case "last":
						z.iv[zxpk].last, err = dc.ReadUint32()
						if err != nil {
							return
						}
					default:
						err = dc.Skip()
						if err != nil {
							return
						}
					}
				}
			}
		case "card":
			z.card, err = dc.ReadInt64()
			if err != nil {
				return
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
Ejemplo n.º 8
0
func (r *Response) DecodeMsg(mr *msgp.Reader) error {
	var bm msgp.Decodable

	if r.Body != nil {
		var ok bool
		bm, ok = r.Body.(msgp.Decodable)
		if !ok {
			return ErrNotDecodable
		}
	}

	if size, err := mr.ReadArrayHeader(); err != nil {
		return err
	} else if size != ResponsePackSize {
		return ErrBadPackSize
	}

	if typ, err := mr.ReadInt(); err != nil {
		return err
	} else if typ != ResponseType {
		return ErrBadMessageType
	}

	id, err := mr.ReadUint32()
	if err != nil {
		return err
	}

	r.ID = id

	// Error can be nil or a string.
	typ, err := mr.NextType()
	if err != nil {
		return err
	}

	switch typ {
	case msgp.StrType:
		s, err := mr.ReadString()
		if err != nil {
			return err
		}
		r.Error = s

	case msgp.NilType:
		if err := mr.ReadNil(); err != nil {
			return err
		}
		r.Error = ""

	default:
		return ErrBadErrorType
	}

	// Body can be nil.
	typ, err = mr.NextType()
	if err != nil {
		return err
	}

	if typ == msgp.NilType {
		r.hasBody = false
		return mr.ReadNil()
	}

	r.hasBody = true

	// Skip decoding the body if no value is present to decode into.
	// The caller is expected to read the body or skip it.
	if bm != nil {
		return decodeBody(mr, bm)
	}

	return nil

}