當前位置: 首頁>>代碼示例>>Golang>>正文


Golang msgp.Reader類代碼示例

本文整理匯總了Golang中github.com/tinylib/msgp/msgp.Reader的典型用法代碼示例。如果您正苦於以下問題:Golang Reader類的具體用法?Golang Reader怎麽用?Golang Reader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Reader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: DecodeMsg

// DecodeMsg implements msgp.Decodable
func (z *Foo) 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 "bar":
			z.Bar, err = dc.ReadString()
			if err != nil {
				return
			}
		case "baz":
			z.Baz, err = dc.ReadFloat64()
			if err != nil {
				return
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
開發者ID:zchee,項目名稱:go-sandbox,代碼行數:35,代碼來源:main_gen.go

示例2: DecodeMsg

// DecodeMsg implements msgp.Decodable
func (z *Message) DecodeMsg(dc *msgp.Reader) (err error) {
	var ssz uint32
	ssz, err = dc.ReadArrayHeader()
	if err != nil {
		return
	}
	if ssz != 4 {
		err = msgp.ArrayError{Wanted: 4, Got: ssz}
		return
	}
	z.Tag, err = dc.ReadString()
	if err != nil {
		return
	}
	z.Time, err = dc.ReadInt64()
	if err != nil {
		return
	}
	z.Record, err = dc.ReadIntf()
	if err != nil {
		return
	}
	z.Option, err = dc.ReadIntf()
	if err != nil {
		return
	}
	return
}
開發者ID:CadeLaRen,項目名稱:docker-3,代碼行數:29,代碼來源:proto_gen.go

示例3: DecodeMsg

// DecodeMsg implements msgp.Decodable
func (z *Incoming) 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 "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
}
開發者ID:sztanpet,項目名稱:bimpc,代碼行數:35,代碼來源:main_gen.go

示例4: DecodeMsg

// DecodeMsg implements msgp.Decodable
func (z *Person) 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 "first":
			z.First, err = dc.ReadString()
			if err != nil {
				return
			}
		case "last":
			z.Last, err = dc.ReadString()
			if err != nil {
				return
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
開發者ID:glycerine,項目名稱:zygomys,代碼行數:35,代碼來源:demo_go_structs_gen.go

示例5: DecodeMsg

// 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
}
開發者ID:RoaringBitmap,項目名稱:roaring,代碼行數:35,代碼來源:rle_gen.go

示例6: DecodeMsg

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
}
開發者ID:micro,項目名稱:go-plugins,代碼行數:59,代碼來源:rpc.go

示例7: DecodeMsg

// DecodeMsg implements msgp.Decodable
func (z *Ztype) DecodeMsg(dc *msgp.Reader) (err error) {
	{
		var zgmo int32
		zgmo, err = dc.ReadInt32()
		(*z) = Ztype(zgmo)
	}
	if err != nil {
		return
	}
	return
}
開發者ID:glycerine,項目名稱:zebra,代碼行數:12,代碼來源:zebra_gen.go

示例8: DecodeMsg

// DecodeMsg implements msgp.Decodable
func (z *Binary) DecodeMsg(dc *msgp.Reader) (err error) {
	{
		var tmp []byte
		tmp, err = dc.ReadBytes([]byte((*z)))
		(*z) = Binary(tmp)
	}
	if err != nil {
		return
	}
	return
}
開發者ID:tartavull,項目名稱:dvid,代碼行數:12,代碼來源:msgpack_gen.go

示例9: DecodeMsg

// DecodeMsg implements msgp.Decodable
func (z *contype) DecodeMsg(dc *msgp.Reader) (err error) {
	{
		var zajw uint8
		zajw, err = dc.ReadUint8()
		(*z) = contype(zajw)
	}
	if err != nil {
		return
	}
	return
}
開發者ID:RoaringBitmap,項目名稱:roaring,代碼行數:12,代碼來源:roaringarray_gen.go

示例10: DecodeMsg

// DecodeMsg implements msgp.Decodable
func (z *DocumentID) DecodeMsg(dc *msgp.Reader) (err error) {
	{
		var tmp uint
		tmp, err = dc.ReadUint()
		(*z) = DocumentID(tmp)
	}
	if err != nil {
		return
	}
	return
}
開發者ID:JustinAzoff,項目名稱:flow-indexer,代碼行數:12,代碼來源:documentlist_msgp_gen.go

示例11: Handle

func (d *initialDispatch) Handle(id uint64, r *msgp.Reader) (Dispatcher, error) {
	var err error
	switch id {
	case spool:
		var opts = make(Profile)
		var name string

		if err = checkSize(_onSpoolArgsNum, r); err != nil {
			return nil, err
		}

		if err = r.ReadMapStrIntf(opts); err != nil {
			return nil, err
		}

		if name, err = r.ReadString(); err != nil {
			return nil, err
		}

		return d.onSpool(opts, name)
	case spawn:
		var (
			opts             = make(Profile)
			name, executable string
			args             = make(map[string]string)
			env              = make(map[string]string)
		)
		if err = checkSize(_onSpawnArgsNum, r); err != nil {
			return nil, err
		}

		if err = r.ReadMapStrIntf(opts); err != nil {
			return nil, err
		}
		if name, err = r.ReadString(); err != nil {
			return nil, err
		}
		if executable, err = r.ReadString(); err != nil {
			return nil, err
		}

		if err = readMapStrStr(r, args); err != nil {
			return nil, err
		}

		if err = readMapStrStr(r, env); err != nil {
			return nil, err
		}

		return d.onSpawn(opts, name, executable, args, env)
	default:
		return nil, fmt.Errorf("unknown transition id: %d", id)
	}
}
開發者ID:noxiouz,項目名稱:stout,代碼行數:54,代碼來源:initialdispatch.go

示例12: Handle

func (d *spawnDispatch) Handle(id int64, r *msgp.Reader) (Dispatcher, error) {
	switch id {
	case spawnKill:
		r.Skip()
		go d.asyncKill()
		// NOTE: do not return an err on purpose
		return nil, nil
	default:
		return nil, fmt.Errorf("unknown transition id: %d", id)
	}
}
開發者ID:terrible-broom,項目名稱:stout,代碼行數:11,代碼來源:spawndispatch.go

示例13: checkSize

func checkSize(num uint32, r *msgp.Reader) error {
	size, err := r.ReadArrayHeader()
	if err != nil {
		return err
	}

	if size != num {
		return ErrInvalidArgsNum
	}

	return nil
}
開發者ID:noxiouz,項目名稱:stout,代碼行數:12,代碼來源:initialdispatch.go

示例14: Handle

func (s *spoolCancelationDispatch) Handle(id uint64, r *msgp.Reader) (Dispatcher, error) {
	switch id {
	case spoolCancel:
		// Skip empty array
		apexctx.GetLogger(s.ctx).Debug("Spool.Cancel()")
		r.Skip()
		// TODO: cancel only if I'm spooling
		s.cancel()
		// NOTE: do not return an err on purpose
		s.stream.Close(s.ctx, replySpoolOk)
		return nil, nil
	default:
		return nil, fmt.Errorf("unknown transition id: %d", id)
	}
}
開發者ID:noxiouz,項目名稱:stout,代碼行數:15,代碼來源:spooldispatch.go

示例15: DecodeMsg

// DecodeMsg implements msgp.Decodable
func (z *arrayContainer) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var zbzg uint32
	zbzg, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for zbzg > 0 {
		zbzg--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "content":
			var zbai uint32
			zbai, err = dc.ReadArrayHeader()
			if err != nil {
				return
			}
			if cap(z.content) >= int(zbai) {
				z.content = (z.content)[:zbai]
			} else {
				z.content = make([]uint16, zbai)
			}
			for zxvk := range z.content {
				z.content[zxvk], err = dc.ReadUint16()
				if err != nil {
					return
				}
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
開發者ID:RoaringBitmap,項目名稱:roaring,代碼行數:42,代碼來源:arraycontainer_gen.go


注:本文中的github.com/tinylib/msgp/msgp.Reader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。