示例#1
0
func _OptionValue_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*OptionValue)
	// value
	switch x := m.Value.(type) {
	case *OptionValue_BoolValue:
		t := uint64(0)
		if x.BoolValue {
			t = 1
		}
		b.EncodeVarint(2<<3 | proto.WireVarint)
		b.EncodeVarint(t)
	case *OptionValue_IntValue:
		b.EncodeVarint(3<<3 | proto.WireVarint)
		b.EncodeVarint(uint64(x.IntValue))
	case *OptionValue_DoubleValue:
		b.EncodeVarint(4<<3 | proto.WireFixed64)
		b.EncodeFixed64(math.Float64bits(x.DoubleValue))
	case *OptionValue_StringValue:
		b.EncodeVarint(5<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.StringValue)
	case *OptionValue_DurationValue:
		b.EncodeVarint(6<<3 | proto.WireVarint)
		b.EncodeVarint(uint64(x.DurationValue))
	case nil:
	default:
		return fmt.Errorf("OptionValue.Value has unexpected type %T", x)
	}
	return nil
}
示例#2
0
func _HttpRule_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*HttpRule)
	// pattern
	switch x := m.Pattern.(type) {
	case *HttpRule_Get:
		b.EncodeVarint(2<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.Get)
	case *HttpRule_Put:
		b.EncodeVarint(3<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.Put)
	case *HttpRule_Post:
		b.EncodeVarint(4<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.Post)
	case *HttpRule_Delete:
		b.EncodeVarint(5<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.Delete)
	case *HttpRule_Patch:
		b.EncodeVarint(6<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.Patch)
	case *HttpRule_Custom:
		b.EncodeVarint(8<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.Custom); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("HttpRule.Pattern has unexpected type %T", x)
	}
	return nil
}
示例#3
0
func _JSON_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*JSON)
	// json_value_oneof
	switch x := m.JsonValueOneof.(type) {
	case *JSON_JsonString:
		b.EncodeVarint(1<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.JsonString)
	case *JSON_JsonNumber:
		b.EncodeVarint(2<<3 | proto.WireFixed64)
		b.EncodeFixed64(math.Float64bits(x.JsonNumber))
	case *JSON_JsonBool:
		t := uint64(0)
		if x.JsonBool {
			t = 1
		}
		b.EncodeVarint(3<<3 | proto.WireVarint)
		b.EncodeVarint(t)
	case *JSON_JsonObject:
		b.EncodeVarint(4<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.JsonObject); err != nil {
			return err
		}
	case *JSON_JsonArray:
		b.EncodeVarint(5<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.JsonArray); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("JSON.JsonValueOneof has unexpected type %T", x)
	}
	return nil
}
示例#4
0
func _RowValue_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*RowValue)
	// value
	switch x := m.Value.(type) {
	case *RowValue_Str:
		_ = b.EncodeVarint(1<<3 | proto.WireBytes)
		_ = b.EncodeStringBytes(x.Str)
	case *RowValue_Int:
		_ = b.EncodeVarint(2<<3 | proto.WireVarint)
		_ = b.EncodeVarint(uint64(x.Int))
	case *RowValue_Real:
		_ = b.EncodeVarint(3<<3 | proto.WireFixed32)
		_ = b.EncodeFixed32(uint64(math.Float32bits(x.Real)))
	case *RowValue_Date:
		_ = b.EncodeVarint(4<<3 | proto.WireVarint)
		_ = b.EncodeVarint(uint64(x.Date))
	case *RowValue_DateOfTime:
		_ = b.EncodeVarint(5<<3 | proto.WireVarint)
		_ = b.EncodeVarint(uint64(x.DateOfTime))
	case *RowValue_TimeOfDay:
		_ = b.EncodeVarint(6<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.TimeOfDay); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("RowValue.Value has unexpected type %T", x)
	}
	return nil
}
示例#5
0
func _Metric_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*Metric)
	// data
	switch x := m.Data.(type) {
	case *Metric_StringData:
		b.EncodeVarint(9<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.StringData)
	case *Metric_Float32Data:
		b.EncodeVarint(10<<3 | proto.WireFixed32)
		b.EncodeFixed32(uint64(math.Float32bits(x.Float32Data)))
	case *Metric_Float64Data:
		b.EncodeVarint(11<<3 | proto.WireFixed64)
		b.EncodeFixed64(math.Float64bits(x.Float64Data))
	case *Metric_Int32Data:
		b.EncodeVarint(12<<3 | proto.WireVarint)
		b.EncodeVarint(uint64(x.Int32Data))
	case *Metric_Int64Data:
		b.EncodeVarint(13<<3 | proto.WireVarint)
		b.EncodeVarint(uint64(x.Int64Data))
	case *Metric_BytesData:
		b.EncodeVarint(14<<3 | proto.WireBytes)
		b.EncodeRawBytes(x.BytesData)
	case *Metric_BoolData:
		t := uint64(0)
		if x.BoolData {
			t = 1
		}
		b.EncodeVarint(15<<3 | proto.WireVarint)
		b.EncodeVarint(t)
	case nil:
	default:
		return fmt.Errorf("Metric.Data has unexpected type %T", x)
	}
	return nil
}
示例#6
0
func _Column_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*Column)
	// value
	switch x := m.Value.(type) {
	case *Column_String_:
		b.EncodeVarint(1<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.String_)
	case *Column_Int32:
		b.EncodeVarint(2<<3 | proto.WireVarint)
		b.EncodeVarint(uint64(x.Int32))
	case *Column_Int64:
		b.EncodeVarint(3<<3 | proto.WireVarint)
		b.EncodeVarint(uint64(x.Int64))
	case *Column_Uint32:
		b.EncodeVarint(4<<3 | proto.WireVarint)
		b.EncodeVarint(uint64(x.Uint32))
	case *Column_Uint64:
		b.EncodeVarint(5<<3 | proto.WireVarint)
		b.EncodeVarint(uint64(x.Uint64))
	case *Column_Bytes:
		b.EncodeVarint(6<<3 | proto.WireBytes)
		b.EncodeRawBytes(x.Bytes)
	case *Column_Bool:
		t := uint64(0)
		if x.Bool {
			t = 1
		}
		b.EncodeVarint(7<<3 | proto.WireVarint)
		b.EncodeVarint(t)
	case nil:
	default:
		return fmt.Errorf("Column.Value has unexpected type %T", x)
	}
	return nil
}
示例#7
0
func _Value_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*Value)
	// value_type
	switch x := m.ValueType.(type) {
	case *Value_NullValue:
		b.EncodeVarint(11<<3 | proto.WireVarint)
		b.EncodeVarint(uint64(x.NullValue))
	case *Value_BooleanValue:
		t := uint64(0)
		if x.BooleanValue {
			t = 1
		}
		b.EncodeVarint(1<<3 | proto.WireVarint)
		b.EncodeVarint(t)
	case *Value_IntegerValue:
		b.EncodeVarint(2<<3 | proto.WireVarint)
		b.EncodeVarint(uint64(x.IntegerValue))
	case *Value_DoubleValue:
		b.EncodeVarint(3<<3 | proto.WireFixed64)
		b.EncodeFixed64(math.Float64bits(x.DoubleValue))
	case *Value_TimestampValue:
		b.EncodeVarint(10<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.TimestampValue); err != nil {
			return err
		}
	case *Value_KeyValue:
		b.EncodeVarint(5<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.KeyValue); err != nil {
			return err
		}
	case *Value_StringValue:
		b.EncodeVarint(17<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.StringValue)
	case *Value_BlobValue:
		b.EncodeVarint(18<<3 | proto.WireBytes)
		b.EncodeRawBytes(x.BlobValue)
	case *Value_GeoPointValue:
		b.EncodeVarint(8<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.GeoPointValue); err != nil {
			return err
		}
	case *Value_EntityValue:
		b.EncodeVarint(6<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.EntityValue); err != nil {
			return err
		}
	case *Value_ArrayValue:
		b.EncodeVarint(9<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.ArrayValue); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("Value.ValueType has unexpected type %T", x)
	}
	return nil
}
示例#8
0
// 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
}
示例#9
0
func _ServerReflectionRequest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*ServerReflectionRequest)
	// message_request
	switch x := m.MessageRequest.(type) {
	case *ServerReflectionRequest_FileByFilename:
		b.EncodeVarint(3<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.FileByFilename)
	case *ServerReflectionRequest_FileContainingSymbol:
		b.EncodeVarint(4<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.FileContainingSymbol)
	case *ServerReflectionRequest_FileContainingExtension:
		b.EncodeVarint(5<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.FileContainingExtension); err != nil {
			return err
		}
	case *ServerReflectionRequest_AllExtensionNumbersOfType:
		b.EncodeVarint(6<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.AllExtensionNumbersOfType)
	case *ServerReflectionRequest_ListServices:
		b.EncodeVarint(7<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.ListServices)
	case nil:
	default:
		return fmt.Errorf("ServerReflectionRequest.MessageRequest has unexpected type %T", x)
	}
	return nil
}
示例#10
0
func _Communique_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*Communique)
	// union
	switch x := m.Union.(type) {
	case *Communique_Number:
		b.EncodeVarint(5<<3 | proto.WireVarint)
		b.EncodeVarint(uint64(x.Number))
	case *Communique_Name:
		b.EncodeVarint(6<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.Name)
	case *Communique_Data:
		b.EncodeVarint(7<<3 | proto.WireBytes)
		b.EncodeRawBytes(x.Data)
	case *Communique_TempC:
		b.EncodeVarint(8<<3 | proto.WireFixed64)
		b.EncodeFixed64(math.Float64bits(x.TempC))
	case *Communique_Height:
		b.EncodeVarint(9<<3 | proto.WireFixed32)
		b.EncodeFixed32(uint64(math.Float32bits(x.Height)))
	case *Communique_Today:
		b.EncodeVarint(10<<3 | proto.WireVarint)
		b.EncodeVarint(uint64(x.Today))
	case *Communique_Maybe:
		t := uint64(0)
		if x.Maybe {
			t = 1
		}
		b.EncodeVarint(11<<3 | proto.WireVarint)
		b.EncodeVarint(t)
	case *Communique_Delta_:
		b.EncodeVarint(12<<3 | proto.WireVarint)
		b.EncodeZigzag32(uint64(x.Delta))
	case *Communique_Msg:
		b.EncodeVarint(13<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.Msg); err != nil {
			return err
		}
	case *Communique_Somegroup:
		b.EncodeVarint(14<<3 | proto.WireStartGroup)
		if err := b.Marshal(x.Somegroup); err != nil {
			return err
		}
		b.EncodeVarint(14<<3 | proto.WireEndGroup)
	case nil:
	default:
		return fmt.Errorf("Communique.Union has unexpected type %T", x)
	}
	return nil
}
示例#11
0
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
}
示例#12
0
func _IPOrDomain_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*IPOrDomain)
	// address
	switch x := m.Address.(type) {
	case *IPOrDomain_Ip:
		b.EncodeVarint(1<<3 | proto.WireBytes)
		b.EncodeRawBytes(x.Ip)
	case *IPOrDomain_Domain:
		b.EncodeVarint(2<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.Domain)
	case nil:
	default:
		return fmt.Errorf("IPOrDomain.Address has unexpected type %T", x)
	}
	return nil
}
示例#13
0
func _Flag_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*Flag)
	// flag
	switch x := m.Flag.(type) {
	case *Flag_Reserved_:
		b.EncodeVarint(1<<3 | proto.WireVarint)
		b.EncodeVarint(uint64(x.Reserved))
	case *Flag_Custom:
		b.EncodeVarint(2<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.Custom)
	case nil:
	default:
		return fmt.Errorf("Flag.Flag has unexpected type %T", x)
	}
	return nil
}
示例#14
0
func _Key_PathElement_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*Key_PathElement)
	// id_type
	switch x := m.IdType.(type) {
	case *Key_PathElement_Id:
		b.EncodeVarint(2<<3 | proto.WireVarint)
		b.EncodeVarint(uint64(x.Id))
	case *Key_PathElement_Name:
		b.EncodeVarint(3<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.Name)
	case nil:
	default:
		return fmt.Errorf("Key_PathElement.IdType has unexpected type %T", x)
	}
	return nil
}
示例#15
0
func _FileServer_Entry_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*FileServer_Entry)
	// FileOrDir
	switch x := m.FileOrDir.(type) {
	case *FileServer_Entry_File:
		b.EncodeVarint(1<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.File)
	case *FileServer_Entry_Directory:
		b.EncodeVarint(2<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.Directory)
	case nil:
	default:
		return fmt.Errorf("FileServer_Entry.FileOrDir has unexpected type %T", x)
	}
	return nil
}
示例#16
0
func _MsgWithOneof_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*MsgWithOneof)
	// union
	switch x := m.Union.(type) {
	case *MsgWithOneof_Title:
		b.EncodeVarint(1<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.Title)
	case *MsgWithOneof_Salary:
		b.EncodeVarint(2<<3 | proto.WireVarint)
		b.EncodeVarint(uint64(x.Salary))
	case nil:
	default:
		return fmt.Errorf("MsgWithOneof.Union has unexpected type %T", x)
	}
	return nil
}
func _Test_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*Test)
	// union
	switch x := m.Union.(type) {
	case *Test_Number:
		b.EncodeVarint(6<<3 | proto.WireVarint)
		b.EncodeVarint(uint64(x.Number))
	case *Test_Name:
		b.EncodeVarint(7<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.Name)
	case nil:
	default:
		return fmt.Errorf("Test.Union has unexpected type %T", x)
	}
	return nil
}
func _ABitOfEverything_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*ABitOfEverything)
	// oneof_value
	switch x := m.OneofValue.(type) {
	case *ABitOfEverything_OneofEmpty:
		b.EncodeVarint(20<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.OneofEmpty); err != nil {
			return err
		}
	case *ABitOfEverything_OneofString:
		b.EncodeVarint(21<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.OneofString)
	case nil:
	default:
		return fmt.Errorf("ABitOfEverything.OneofValue has unexpected type %T", x)
	}
	return nil
}
示例#19
0
func _JobInfo_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*JobInfo)
	// spec
	switch x := m.Spec.(type) {
	case *JobInfo_Transform:
		b.EncodeVarint(2<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.Transform); err != nil {
			return err
		}
	case *JobInfo_PipelineName:
		b.EncodeVarint(3<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.PipelineName)
	case nil:
	default:
		return fmt.Errorf("JobInfo.Spec has unexpected type %T", x)
	}
	return nil
}
示例#20
0
// Marshal serializes a `KVWrite`
func (w *KVWrite) Marshal(buf *proto.Buffer) error {
	var err error
	if err = buf.EncodeStringBytes(w.Key); err != nil {
		return err
	}
	deleteMarker := 0
	if w.IsDelete {
		deleteMarker = 1
	}
	if err = buf.EncodeVarint(uint64(deleteMarker)); err != nil {
		return err
	}
	if deleteMarker == 0 {
		if err = buf.EncodeRawBytes(w.Value); err != nil {
			return err
		}
	}
	return nil
}
示例#21
0
// Marshal serializes a `NsReadWriteSet`
func (nsRW *NsReadWriteSet) Marshal(buf *proto.Buffer) error {
	var err error
	if err = buf.EncodeStringBytes(nsRW.NameSpace); err != nil {
		return err
	}
	if err = buf.EncodeVarint(uint64(len(nsRW.Reads))); err != nil {
		return err
	}
	for i := 0; i < len(nsRW.Reads); i++ {
		nsRW.Reads[i].Marshal(buf)
	}
	if err = buf.EncodeVarint(uint64(len(nsRW.Writes))); err != nil {
		return err
	}
	for i := 0; i < len(nsRW.Writes); i++ {
		nsRW.Writes[i].Marshal(buf)
	}
	return nil
}
示例#22
0
func _GaugeResponse_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*GaugeResponse)
	// value
	switch x := m.Value.(type) {
	case *GaugeResponse_LongValue:
		b.EncodeVarint(2<<3 | proto.WireVarint)
		b.EncodeVarint(uint64(x.LongValue))
	case *GaugeResponse_DoubleValue:
		b.EncodeVarint(3<<3 | proto.WireFixed64)
		b.EncodeFixed64(math.Float64bits(x.DoubleValue))
	case *GaugeResponse_StringValue:
		b.EncodeVarint(4<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.StringValue)
	case nil:
	default:
		return fmt.Errorf("GaugeResponse.Value has unexpected type %T", x)
	}
	return nil
}
示例#23
0
func _Field_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*Field)
	// value
	switch x := m.Value.(type) {
	case *Field_Number:
		b.EncodeVarint(2<<3 | proto.WireFixed64)
		b.EncodeFixed64(math.Float64bits(x.Number))
	case *Field_Str:
		b.EncodeVarint(3<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.Str)
	case *Field_Boolean:
		t := uint64(0)
		if x.Boolean {
			t = 1
		}
		b.EncodeVarint(4<<3 | proto.WireVarint)
		b.EncodeVarint(t)
	case *Field_Object:
		b.EncodeVarint(5<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.Object); err != nil {
			return err
		}
	case *Field_Array:
		b.EncodeVarint(6<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.Array); err != nil {
			return err
		}
	case *Field_Link:
		b.EncodeVarint(7<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.Link); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("Field.Value has unexpected type %T", x)
	}
	return nil
}
示例#24
0
func _LogEntry_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*LogEntry)
	// payload
	switch x := m.Payload.(type) {
	case *LogEntry_ProtoPayload:
		b.EncodeVarint(2<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.ProtoPayload); err != nil {
			return err
		}
	case *LogEntry_TextPayload:
		b.EncodeVarint(3<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.TextPayload)
	case *LogEntry_JsonPayload:
		b.EncodeVarint(6<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.JsonPayload); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("LogEntry.Payload has unexpected type %T", x)
	}
	return nil
}
示例#25
0
func _TestQuery_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*TestQuery)
	// query
	switch x := m.Query.(type) {
	case *TestQuery_Id:
		b.EncodeVarint(1<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.Id)
	case *TestQuery_Wildcard_:
		b.EncodeVarint(2<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.Wildcard); err != nil {
			return err
		}
	case *TestQuery_Regex_:
		b.EncodeVarint(3<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.Regex); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("TestQuery.Query has unexpected type %T", x)
	}
	return nil
}
示例#26
0
func _Argument_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*Argument)
	// value
	switch x := m.Value.(type) {
	case *Argument_Number:
		b.EncodeVarint(1<<3 | proto.WireFixed64)
		b.EncodeFixed64(math.Float64bits(x.Number))
	case *Argument_Str:
		b.EncodeVarint(2<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.Str)
	case *Argument_Boolean:
		t := uint64(0)
		if x.Boolean {
			t = 1
		}
		b.EncodeVarint(3<<3 | proto.WireVarint)
		b.EncodeVarint(t)
	case nil:
	default:
		return fmt.Errorf("Argument.Value has unexpected type %T", x)
	}
	return nil
}
示例#27
0
func _Value_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
	m := msg.(*Value)
	// kind
	switch x := m.Kind.(type) {
	case *Value_NullValue:
		b.EncodeVarint(1<<3 | proto.WireVarint)
		b.EncodeVarint(uint64(x.NullValue))
	case *Value_NumberValue:
		b.EncodeVarint(2<<3 | proto.WireFixed64)
		b.EncodeFixed64(math.Float64bits(x.NumberValue))
	case *Value_StringValue:
		b.EncodeVarint(3<<3 | proto.WireBytes)
		b.EncodeStringBytes(x.StringValue)
	case *Value_BoolValue:
		t := uint64(0)
		if x.BoolValue {
			t = 1
		}
		b.EncodeVarint(4<<3 | proto.WireVarint)
		b.EncodeVarint(t)
	case *Value_StructValue:
		b.EncodeVarint(5<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.StructValue); err != nil {
			return err
		}
	case *Value_ListValue:
		b.EncodeVarint(6<<3 | proto.WireBytes)
		if err := b.EncodeMessage(x.ListValue); err != nil {
			return err
		}
	case nil:
	default:
		return fmt.Errorf("Value.Kind has unexpected type %T", x)
	}
	return nil
}
示例#28
0
func (chaincodeStateDelta *chaincodeStateDelta) marshal(buffer *proto.Buffer) {
	err := buffer.EncodeVarint(uint64(len(chaincodeStateDelta.updatedKVs)))
	if err != nil {
		// in protobuf code the error return is always nil
		panic(fmt.Errorf("This error should not occur: %s", err))
	}
	for key, valueHolder := range chaincodeStateDelta.updatedKVs {
		err = buffer.EncodeStringBytes(key)
		if err != nil {
			return
		}
		err = buffer.EncodeRawBytes(valueHolder.value)
		if err != nil {
			// in protobuf code the error return is always nil
			panic(fmt.Errorf("This error should not occur: %s", err))
		}
		err = buffer.EncodeRawBytes(valueHolder.previousValue)
		if err != nil {
			// in protobuf code the error return is always nil
			panic(fmt.Errorf("This error should not occur: %s", err))
		}
	}
	return
}