本文整理汇总了Golang中github.com/golang/protobuf/proto.Buffer.DecodeRawBytes方法的典型用法代码示例。如果您正苦于以下问题:Golang Buffer.DecodeRawBytes方法的具体用法?Golang Buffer.DecodeRawBytes怎么用?Golang Buffer.DecodeRawBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/golang/protobuf/proto.Buffer
的用法示例。
在下文中一共展示了Buffer.DecodeRawBytes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: _ReadRowsRequest_OneofUnmarshaler
func _ReadRowsRequest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*ReadRowsRequest)
switch tag {
case 2: // target.row_key
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
m.Target = &ReadRowsRequest_RowKey{x}
return true, err
case 3: // target.row_range
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(google_bigtable_v11.RowRange)
err := b.DecodeMessage(msg)
m.Target = &ReadRowsRequest_RowRange{msg}
return true, err
case 8: // target.row_set
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(google_bigtable_v11.RowSet)
err := b.DecodeMessage(msg)
m.Target = &ReadRowsRequest_RowSet{msg}
return true, err
default:
return false, nil
}
}
示例2: _BatchMessage_OneofUnmarshaler
func _BatchMessage_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*BatchMessage)
switch tag {
case 1: // payload.request
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Request)
err := b.DecodeMessage(msg)
m.Payload = &BatchMessage_Request{msg}
return true, err
case 4: // payload.pbft_message
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
m.Payload = &BatchMessage_PbftMessage{x}
return true, err
case 5: // payload.complaint
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Request)
err := b.DecodeMessage(msg)
m.Payload = &BatchMessage_Complaint{msg}
return true, err
default:
return false, nil
}
}
示例3: _Metric_OneofUnmarshaler
func _Metric_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*Metric)
switch tag {
case 9: // data.string_data
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.Data = &Metric_StringData{x}
return true, err
case 10: // data.float32_data
if wire != proto.WireFixed32 {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeFixed32()
m.Data = &Metric_Float32Data{math.Float32frombits(uint32(x))}
return true, err
case 11: // data.float64_data
if wire != proto.WireFixed64 {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeFixed64()
m.Data = &Metric_Float64Data{math.Float64frombits(x)}
return true, err
case 12: // data.int32_data
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Data = &Metric_Int32Data{int32(x)}
return true, err
case 13: // data.int64_data
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Data = &Metric_Int64Data{int64(x)}
return true, err
case 14: // data.bytes_data
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
m.Data = &Metric_BytesData{x}
return true, err
case 15: // data.bool_data
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Data = &Metric_BoolData{x != 0}
return true, err
default:
return false, nil
}
}
示例4: _Column_OneofUnmarshaler
func _Column_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*Column)
switch tag {
case 1: // value.string
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.Value = &Column_String_{x}
return true, err
case 2: // value.int32
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Value = &Column_Int32{int32(x)}
return true, err
case 3: // value.int64
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Value = &Column_Int64{int64(x)}
return true, err
case 4: // value.uint32
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Value = &Column_Uint32{uint32(x)}
return true, err
case 5: // value.uint64
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Value = &Column_Uint64{x}
return true, err
case 6: // value.bytes
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
m.Value = &Column_Bytes{x}
return true, err
case 7: // value.bool
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Value = &Column_Bool{x != 0}
return true, err
default:
return false, nil
}
}
示例5: _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
}
}
示例6: 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
}
示例7: 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
}
示例8: unmarshalValueWithMarker
func (chaincodeStateDelta *ChaincodeStateDelta) unmarshalValueWithMarker(buffer *proto.Buffer) ([]byte, error) {
valueMarker, err := buffer.DecodeVarint()
if err != nil {
return nil, fmt.Errorf("Error unmarshaling state delta : %s", err)
}
if valueMarker == 0 {
return nil, nil
}
value, err := buffer.DecodeRawBytes(false)
if err != nil {
return nil, fmt.Errorf("Error unmarhsaling state delta : %s", err)
}
// protobuff makes an empty []byte into a nil. So, assigning an empty byte array explicitly
if value == nil {
value = []byte{}
}
return value, nil
}
示例9: _DropRowRangeRequest_OneofUnmarshaler
func _DropRowRangeRequest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*DropRowRangeRequest)
switch tag {
case 2: // target.row_key_prefix
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
m.Target = &DropRowRangeRequest_RowKeyPrefix{x}
return true, err
case 3: // target.delete_all_data_from_table
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Target = &DropRowRangeRequest_DeleteAllDataFromTable{x != 0}
return true, err
default:
return false, nil
}
}
示例10: _IPOrDomain_OneofUnmarshaler
func _IPOrDomain_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*IPOrDomain)
switch tag {
case 1: // address.ip
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
m.Address = &IPOrDomain_Ip{x}
return true, err
case 2: // address.domain
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.Address = &IPOrDomain_Domain{x}
return true, err
default:
return false, nil
}
}
示例11: _ReadOptions_OneofUnmarshaler
func _ReadOptions_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*ReadOptions)
switch tag {
case 1: // consistency_type.read_consistency
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.ConsistencyType = &ReadOptions_ReadConsistency_{ReadOptions_ReadConsistency(x)}
return true, err
case 2: // consistency_type.transaction
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
m.ConsistencyType = &ReadOptions_Transaction{x}
return true, err
default:
return false, nil
}
}
示例12: _GqlQueryParameter_OneofUnmarshaler
func _GqlQueryParameter_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*GqlQueryParameter)
switch tag {
case 2: // parameter_type.value
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Value)
err := b.DecodeMessage(msg)
m.ParameterType = &GqlQueryParameter_Value{msg}
return true, err
case 3: // parameter_type.cursor
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
m.ParameterType = &GqlQueryParameter_Cursor{x}
return true, err
default:
return false, nil
}
}
示例13: _PrintContent_OneofUnmarshaler
func _PrintContent_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*PrintContent)
switch tag {
case 1: // print_content_type.printInfo
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(PrintInfo)
err := b.DecodeMessage(msg)
m.PrintContentType = &PrintContent_PrintInfo{msg}
return true, err
case 2: // print_content_type.content
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
m.PrintContentType = &PrintContent_Content{x}
return true, err
default:
return false, nil
}
}
示例14: unmarshal
func (chaincodeStateDelta *chaincodeStateDelta) unmarshal(buffer *proto.Buffer) error {
size, err := buffer.DecodeVarint()
if err != nil {
panic(fmt.Errorf("This error should not occur: %s", err))
}
chaincodeStateDelta.updatedKVs = make(map[string]*UpdatedValue, size)
for i := uint64(0); i < size; i++ {
key, err := buffer.DecodeStringBytes()
if err != nil {
panic(fmt.Errorf("This error should not occur: %s", err))
}
value, err := buffer.DecodeRawBytes(false)
if err != nil {
panic(fmt.Errorf("This error should not occur: %s", err))
}
// protobuff does not differentiate between an empty []byte or a nil
// For now we assume user does not have a motivation to store []byte array
// as a value for a key and we treat an empty []byte represent that the value was nil
// during marshalling (i.e., the entry represent a delete of a key)
// If we need to differentiate, we need to write a flag during marshalling
//(which would require one bool per keyvalue entry)
if len(value) == 0 {
value = nil
}
previousValue, err := buffer.DecodeRawBytes(false)
if err != nil {
panic(fmt.Errorf("This error should not occur: %s", err))
}
if len(previousValue) == 0 {
previousValue = nil
}
chaincodeStateDelta.updatedKVs[key] = &UpdatedValue{value, previousValue}
}
return nil
}
示例15: _SieveMessage_OneofUnmarshaler
func _SieveMessage_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*SieveMessage)
switch tag {
case 1: // payload.request
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
m.Payload = &SieveMessage_Request{x}
return true, err
case 2: // payload.execute
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Execute)
err := b.DecodeMessage(msg)
m.Payload = &SieveMessage_Execute{msg}
return true, err
case 3: // payload.verify
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Verify)
err := b.DecodeMessage(msg)
m.Payload = &SieveMessage_Verify{msg}
return true, err
case 4: // payload.pbft_message
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
m.Payload = &SieveMessage_PbftMessage{x}
return true, err
default:
return false, nil
}
}