• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang proto.Buffer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/golang/protobuf/proto.Buffer的典型用法代码示例。如果您正苦于以下问题:Golang Buffer类的具体用法?Golang Buffer怎么用?Golang Buffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Buffer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: Marshal

// Marshal serializes a `KVRead`
func (r *KVRead) Marshal(buf *proto.Buffer) error {
	if err := buf.EncodeStringBytes(r.Key); err != nil {
		return err
	}
	versionBytes := []byte{}
	if r.Version != nil {
		versionBytes = r.Version.ToBytes()
	}
	if err := buf.EncodeRawBytes(versionBytes); err != nil {
		return err
	}
	return nil
}
开发者ID:hyperledger,项目名称:fabric,代码行数:14,代码来源:rwset.go


示例2: _CommitRequest_OneofMarshaler

func _CommitRequest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*CommitRequest)
	// transaction_selector
	switch x := m.TransactionSelector.(type) {
	case *CommitRequest_Transaction:
		b.EncodeVarint(1<<3 | proto.WireBytes)
		b.EncodeRawBytes(x.Transaction)
	case nil:
	default:
		return fmt.Errorf("CommitRequest.TransactionSelector has unexpected type %T", x)
	}
	return nil
}
开发者ID:takbok,项目名称:shared-contacts-admin,代码行数:13,代码来源:datastore.pb.go


示例3: unmarshalTrieNodeValueFromBuffer

func unmarshalTrieNodeValueFromBuffer(buffer *proto.Buffer) []byte {
	valueMarker, err := buffer.DecodeVarint()
	if err != nil {
		panic(fmt.Errorf("This error is not excpected: %s", err))
	}
	if valueMarker == 0 {
		return nil
	}
	value, err := buffer.DecodeRawBytes(false)
	if err != nil {
		panic(fmt.Errorf("This error is not excpected: %s", err))
	}
	return value
}
开发者ID:magooster,项目名称:obc-peer,代码行数:14,代码来源:trie_node.go


示例4: _CommitRequest_OneofUnmarshaler

func _CommitRequest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*CommitRequest)
	switch tag {
	case 1: // transaction_selector.transaction
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		x, err := b.DecodeRawBytes(true)
		m.TransactionSelector = &CommitRequest_Transaction{x}
		return true, err
	default:
		return false, nil
	}
}
开发者ID:takbok,项目名称:shared-contacts-admin,代码行数:14,代码来源:datastore.pb.go


示例5: Unmarshal

// Unmarshal deserializes a `KVRead`
func (r *KVRead) Unmarshal(buf *proto.Buffer) error {
	var err error
	var versionBytes []byte
	if r.Key, err = buf.DecodeStringBytes(); err != nil {
		return err
	}
	if versionBytes, err = buf.DecodeRawBytes(false); err != nil {
		return err
	}
	if len(versionBytes) > 0 {
		r.Version, _ = version.NewHeightFromBytes(versionBytes)
	}
	return nil
}
开发者ID:hyperledger,项目名称:fabric,代码行数:15,代码来源:rwset.go


示例6: _MsgWithOneof_OneofUnmarshaler

func _MsgWithOneof_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*MsgWithOneof)
	switch tag {
	case 1: // union.title
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		x, err := b.DecodeStringBytes()
		m.Union = &MsgWithOneof_Title{x}
		return true, err
	case 2: // union.salary
		if wire != proto.WireVarint {
			return true, proto.ErrInternalBadWireType
		}
		x, err := b.DecodeVarint()
		m.Union = &MsgWithOneof_Salary{int64(x)}
		return true, err
	case 3: // union.Country
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		x, err := b.DecodeStringBytes()
		m.Union = &MsgWithOneof_Country{x}
		return true, err
	case 4: // union.home_address
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		x, err := b.DecodeStringBytes()
		m.Union = &MsgWithOneof_HomeAddress{x}
		return true, err
	default:
		return false, nil
	}
}
开发者ID:estesp,项目名称:containerd,代码行数:35,代码来源:test_objects.pb.go


示例7: _Interest_OneofUnmarshaler

func _Interest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*Interest)
	switch tag {
	case 2: // RegInfo.chaincodeRegInfo
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(ChaincodeReg)
		err := b.DecodeMessage(msg)
		m.RegInfo = &Interest_ChaincodeRegInfo{msg}
		return true, err
	default:
		return false, nil
	}
}
开发者ID:yoshiharay,项目名称:fabric,代码行数:15,代码来源:events.pb.go


示例8: _Interest_OneofMarshaler

func _Interest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*Interest)
	// RegInfo
	switch x := m.RegInfo.(type) {
	case *Interest_ChaincodeRegInfo:
		b.EncodeVarint(2<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.ChaincodeRegInfo); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("Interest.RegInfo has unexpected type %T", x)
	}
	return nil
}
开发者ID:yoshiharay,项目名称:fabric,代码行数:15,代码来源:events.pb.go


示例9: _Message_OneofUnmarshaler

func _Message_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*Message)
	switch tag {
	case 1: // protocol.lorawan
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(lorawan.Message)
		err := b.DecodeMessage(msg)
		m.Protocol = &Message_Lorawan{msg}
		return true, err
	default:
		return false, nil
	}
}
开发者ID:TheThingsNetwork,项目名称:ttn,代码行数:15,代码来源:protocol.pb.go


示例10: _ZoneServerMsg_OneofMarshaler

func _ZoneServerMsg_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*ZoneServerMsg)
	// Msg
	switch x := m.Msg.(type) {
	case *ZoneServerMsg_ForWardZoneStartupMsg:
		b.EncodeVarint(1<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.ForWardZoneStartupMsg); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("ZoneServerMsg.Msg has unexpected type %T", x)
	}
	return nil
}
开发者ID:congrihao666,项目名称:jzServer,代码行数:15,代码来源:ZoneServerMsg.pb.go


示例11: _ZoneServerMsg_OneofUnmarshaler

func _ZoneServerMsg_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*ZoneServerMsg)
	switch tag {
	case 1: // Msg.ForWardZoneStartupMsg
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(ForWardZoneStartupMsg)
		err := b.DecodeMessage(msg)
		m.Msg = &ZoneServerMsg_ForWardZoneStartupMsg{msg}
		return true, err
	default:
		return false, nil
	}
}
开发者ID:congrihao666,项目名称:jzServer,代码行数:15,代码来源:ZoneServerMsg.pb.go


示例12: _PipelineSource_OneofMarshaler

func _PipelineSource_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*PipelineSource)
	// typed_pipeline_source
	switch x := m.TypedPipelineSource.(type) {
	case *PipelineSource_GithubPipelineSource:
		b.EncodeVarint(4<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.GithubPipelineSource); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("PipelineSource.TypedPipelineSource has unexpected type %T", x)
	}
	return nil
}
开发者ID:sr,项目名称:pachyderm,代码行数:15,代码来源:pps.pb.go


示例13: marshal

func (chaincodeStateDelta *ChaincodeStateDelta) marshal(buffer *proto.Buffer) {
	err := buffer.EncodeVarint(uint64(len(chaincodeStateDelta.UpdatedKVs)))
	if err != nil {
		panic(fmt.Errorf("This error should not occur: %s", err))
	}
	for key, valueHolder := range chaincodeStateDelta.UpdatedKVs {
		err = buffer.EncodeStringBytes(key)
		if err != nil {
			panic(fmt.Errorf("This error should not occur: %s", err))
		}
		chaincodeStateDelta.marshalValueWithMarker(buffer, valueHolder.Value)
		chaincodeStateDelta.marshalValueWithMarker(buffer, valueHolder.PreviousValue)
	}
	return
}
开发者ID:yoshiharay,项目名称:fabric,代码行数:15,代码来源:state_delta.go


示例14: _PipelineSource_OneofUnmarshaler

func _PipelineSource_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*PipelineSource)
	switch tag {
	case 4: // typed_pipeline_source.github_pipeline_source
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(GithubPipelineSource)
		err := b.DecodeMessage(msg)
		m.TypedPipelineSource = &PipelineSource_GithubPipelineSource{msg}
		return true, err
	default:
		return false, nil
	}
}
开发者ID:sr,项目名称:pachyderm,代码行数:15,代码来源:pps.pb.go


示例15: _Policy_OneofUnmarshaler

func _Policy_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*Policy)
	switch tag {
	case 1: // Type.SignaturePolicy
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(SignaturePolicyEnvelope)
		err := b.DecodeMessage(msg)
		m.Type = &Policy_SignaturePolicy{msg}
		return true, err
	default:
		return false, nil
	}
}
开发者ID:hyperledger,项目名称:fabric,代码行数:15,代码来源:configuration.pb.go


示例16: _Policy_OneofMarshaler

func _Policy_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*Policy)
	// Type
	switch x := m.Type.(type) {
	case *Policy_SignaturePolicy:
		b.EncodeVarint(1<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.SignaturePolicy); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("Policy.Type has unexpected type %T", x)
	}
	return nil
}
开发者ID:hyperledger,项目名称:fabric,代码行数:15,代码来源:configuration.pb.go


示例17: _ArchiveServerConfig_OneofUnmarshaler

func _ArchiveServerConfig_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*ArchiveServerConfig)
	switch tag {
	case 3: // credentials.ssl_credentials
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(ArchiveServerConfig_SslCredentials)
		err := b.DecodeMessage(msg)
		m.Credentials = &ArchiveServerConfig_SslCredentials_{msg}
		return true, err
	default:
		return false, nil
	}
}
开发者ID:bacsorg,项目名称:archive,代码行数:15,代码来源:archive.pb.go


示例18: _ArchiveServerConfig_OneofMarshaler

func _ArchiveServerConfig_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*ArchiveServerConfig)
	// credentials
	switch x := m.Credentials.(type) {
	case *ArchiveServerConfig_SslCredentials_:
		b.EncodeVarint(3<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.SslCredentials); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("ArchiveServerConfig.Credentials has unexpected type %T", x)
	}
	return nil
}
开发者ID:bacsorg,项目名称:archive,代码行数:15,代码来源:archive.pb.go


示例19: _WatchRequest_OneofUnmarshaler

func _WatchRequest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
	m := msg.(*WatchRequest)
	switch tag {
	case 1: // request_union.create_request
		if wire != proto.WireBytes {
			return true, proto.ErrInternalBadWireType
		}
		msg := new(WatchCreateRequest)
		err := b.DecodeMessage(msg)
		m.RequestUnion = &WatchRequest_CreateRequest{msg}
		return true, err
	default:
		return false, nil
	}
}
开发者ID:gyuho,项目名称:learn,代码行数:15,代码来源:rpc.pb.go


示例20: _WatchRequest_OneofMarshaler

func _WatchRequest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*WatchRequest)
	// request_union
	switch x := m.RequestUnion.(type) {
	case *WatchRequest_CreateRequest:
		b.EncodeVarint(1<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.CreateRequest); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("WatchRequest.RequestUnion has unexpected type %T", x)
	}
	return nil
}
开发者ID:gyuho,项目名称:learn,代码行数:15,代码来源:rpc.pb.go



注:本文中的github.com/golang/protobuf/proto.Buffer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang proto.Message类代码示例发布时间:2022-05-23
下一篇:
Golang proto.UnmarshalText函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap