本文整理汇总了Golang中github.com/golang/protobuf/proto.SizeVarint函数的典型用法代码示例。如果您正苦于以下问题:Golang SizeVarint函数的具体用法?Golang SizeVarint怎么用?Golang SizeVarint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SizeVarint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: _Metric_OneofSizer
func _Metric_OneofSizer(msg proto.Message) (n int) {
m := msg.(*Metric)
// data
switch x := m.Data.(type) {
case *Metric_StringData:
n += proto.SizeVarint(9<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.StringData)))
n += len(x.StringData)
case *Metric_Float32Data:
n += proto.SizeVarint(10<<3 | proto.WireFixed32)
n += 4
case *Metric_Float64Data:
n += proto.SizeVarint(11<<3 | proto.WireFixed64)
n += 8
case *Metric_Int32Data:
n += proto.SizeVarint(12<<3 | proto.WireVarint)
n += proto.SizeVarint(uint64(x.Int32Data))
case *Metric_Int64Data:
n += proto.SizeVarint(13<<3 | proto.WireVarint)
n += proto.SizeVarint(uint64(x.Int64Data))
case *Metric_BytesData:
n += proto.SizeVarint(14<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.BytesData)))
n += len(x.BytesData)
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例2: _ServerReflectionRequest_OneofSizer
func _ServerReflectionRequest_OneofSizer(msg proto.Message) (n int) {
m := msg.(*ServerReflectionRequest)
// message_request
switch x := m.MessageRequest.(type) {
case *ServerReflectionRequest_FileByFilename:
n += proto.SizeVarint(3<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.FileByFilename)))
n += len(x.FileByFilename)
case *ServerReflectionRequest_FileContainingSymbol:
n += proto.SizeVarint(4<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.FileContainingSymbol)))
n += len(x.FileContainingSymbol)
case *ServerReflectionRequest_FileContainingExtension:
s := proto.Size(x.FileContainingExtension)
n += proto.SizeVarint(5<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *ServerReflectionRequest_AllExtensionNumbersOfType:
n += proto.SizeVarint(6<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.AllExtensionNumbersOfType)))
n += len(x.AllExtensionNumbersOfType)
case *ServerReflectionRequest_ListServices:
n += proto.SizeVarint(7<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.ListServices)))
n += len(x.ListServices)
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例3: _Field_OneofSizer
func _Field_OneofSizer(msg proto.Message) (n int) {
m := msg.(*Field)
// value
switch x := m.Value.(type) {
case *Field_Number:
n += proto.SizeVarint(2<<3 | proto.WireFixed64)
n += 8
case *Field_Str:
n += proto.SizeVarint(3<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.Str)))
n += len(x.Str)
case *Field_Boolean:
n += proto.SizeVarint(4<<3 | proto.WireVarint)
n += 1
case *Field_Object:
s := proto.Size(x.Object)
n += proto.SizeVarint(5<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Field_Array:
s := proto.Size(x.Array)
n += proto.SizeVarint(6<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Field_Link:
s := proto.Size(x.Link)
n += proto.SizeVarint(7<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例4: _Value_OneofSizer
func _Value_OneofSizer(msg proto.Message) (n int) {
m := msg.(*Value)
// kind
switch x := m.Kind.(type) {
case *Value_NullValue:
n += proto.SizeVarint(1<<3 | proto.WireVarint)
n += proto.SizeVarint(uint64(x.NullValue))
case *Value_NumberValue:
n += proto.SizeVarint(2<<3 | proto.WireFixed64)
n += 8
case *Value_StringValue:
n += proto.SizeVarint(3<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.StringValue)))
n += len(x.StringValue)
case *Value_BoolValue:
n += proto.SizeVarint(4<<3 | proto.WireVarint)
n += 1
case *Value_StructValue:
s := proto.Size(x.StructValue)
n += proto.SizeVarint(5<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Value_ListValue:
s := proto.Size(x.ListValue)
n += proto.SizeVarint(6<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例5: _LoadParams_OneofSizer
func _LoadParams_OneofSizer(msg proto.Message) (n int) {
m := msg.(*LoadParams)
// load
switch x := m.Load.(type) {
case *LoadParams_ClosedLoop:
s := proto.Size(x.ClosedLoop)
n += proto.SizeVarint(1<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *LoadParams_Poisson:
s := proto.Size(x.Poisson)
n += proto.SizeVarint(2<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *LoadParams_Uniform:
s := proto.Size(x.Uniform)
n += proto.SizeVarint(3<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *LoadParams_Determ:
s := proto.Size(x.Determ)
n += proto.SizeVarint(4<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *LoadParams_Pareto:
s := proto.Size(x.Pareto)
n += proto.SizeVarint(5<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例6: _Event_OneofSizer
func _Event_OneofSizer(msg proto.Message) (n int) {
m := msg.(*Event)
// Event
switch x := m.Event.(type) {
case *Event_Register:
s := proto.Size(x.Register)
n += proto.SizeVarint(1<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Event_Block:
s := proto.Size(x.Block)
n += proto.SizeVarint(2<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Event_ChaincodeEvent:
s := proto.Size(x.ChaincodeEvent)
n += proto.SizeVarint(3<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Event_Rejection:
s := proto.Size(x.Rejection)
n += proto.SizeVarint(4<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Event_Unregister:
s := proto.Size(x.Unregister)
n += proto.SizeVarint(5<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例7: _Cred_OneofSizer
func _Cred_OneofSizer(msg proto.Message) (n int) {
m := msg.(*Cred)
// statement
switch x := m.Statement.(type) {
case *Cred_HumanReadable:
s := proto.Size(x.HumanReadable)
n += proto.SizeVarint(7<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Cred_CredSeen:
s := proto.Size(x.CredSeen)
n += proto.SizeVarint(8<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Cred_ApplicationSpecific:
s := proto.Size(x.ApplicationSpecific)
n += proto.SizeVarint(9<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Cred_IdentityDeclaration:
s := proto.Size(x.IdentityDeclaration)
n += proto.SizeVarint(10<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例8: _ServerReflectionResponse_OneofSizer
func _ServerReflectionResponse_OneofSizer(msg proto.Message) (n int) {
m := msg.(*ServerReflectionResponse)
// message_response
switch x := m.MessageResponse.(type) {
case *ServerReflectionResponse_FileDescriptorResponse:
s := proto.Size(x.FileDescriptorResponse)
n += proto.SizeVarint(4<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *ServerReflectionResponse_AllExtensionNumbersResponse:
s := proto.Size(x.AllExtensionNumbersResponse)
n += proto.SizeVarint(5<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *ServerReflectionResponse_ListServicesResponse:
s := proto.Size(x.ListServicesResponse)
n += proto.SizeVarint(6<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *ServerReflectionResponse_ErrorResponse:
s := proto.Size(x.ErrorResponse)
n += proto.SizeVarint(7<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例9: _OptionValue_OneofSizer
func _OptionValue_OneofSizer(msg proto.Message) (n int) {
m := msg.(*OptionValue)
// value
switch x := m.Value.(type) {
case *OptionValue_BoolValue:
n += proto.SizeVarint(2<<3 | proto.WireVarint)
n += 1
case *OptionValue_IntValue:
n += proto.SizeVarint(3<<3 | proto.WireVarint)
n += proto.SizeVarint(uint64(x.IntValue))
case *OptionValue_DoubleValue:
n += proto.SizeVarint(4<<3 | proto.WireFixed64)
n += 8
case *OptionValue_StringValue:
n += proto.SizeVarint(5<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.StringValue)))
n += len(x.StringValue)
case *OptionValue_DurationValue:
n += proto.SizeVarint(6<<3 | proto.WireVarint)
n += proto.SizeVarint(uint64(x.DurationValue))
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例10: _BatchMessage_OneofSizer
func _BatchMessage_OneofSizer(msg proto.Message) (n int) {
m := msg.(*BatchMessage)
// payload
switch x := m.Payload.(type) {
case *BatchMessage_Request:
s := proto.Size(x.Request)
n += proto.SizeVarint(1<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *BatchMessage_RequestBatch:
s := proto.Size(x.RequestBatch)
n += proto.SizeVarint(2<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *BatchMessage_PbftMessage:
n += proto.SizeVarint(3<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.PbftMessage)))
n += len(x.PbftMessage)
case *BatchMessage_Complaint:
s := proto.Size(x.Complaint)
n += proto.SizeVarint(4<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例11: _CommitRequest_OneofSizer
func _CommitRequest_OneofSizer(msg proto.Message) (n int) {
m := msg.(*CommitRequest)
// transaction_selector
switch x := m.TransactionSelector.(type) {
case *CommitRequest_Transaction:
n += proto.SizeVarint(1<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.Transaction)))
n += len(x.Transaction)
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例12: _Mutation_OneofSizer
func _Mutation_OneofSizer(msg proto.Message) (n int) {
m := msg.(*Mutation)
// operation
switch x := m.Operation.(type) {
case *Mutation_Insert:
s := proto.Size(x.Insert)
n += proto.SizeVarint(4<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Mutation_Update:
s := proto.Size(x.Update)
n += proto.SizeVarint(5<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Mutation_Upsert:
s := proto.Size(x.Upsert)
n += proto.SizeVarint(6<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Mutation_Delete:
s := proto.Size(x.Delete)
n += proto.SizeVarint(7<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例13: _MsgWithOneof_OneofSizer
func _MsgWithOneof_OneofSizer(msg proto.Message) (n int) {
m := msg.(*MsgWithOneof)
// union
switch x := m.Union.(type) {
case *MsgWithOneof_Title:
n += proto.SizeVarint(1<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.Title)))
n += len(x.Title)
case *MsgWithOneof_Salary:
n += proto.SizeVarint(2<<3 | proto.WireVarint)
n += proto.SizeVarint(uint64(x.Salary))
case *MsgWithOneof_Country:
n += proto.SizeVarint(3<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.Country)))
n += len(x.Country)
case *MsgWithOneof_HomeAddress:
n += proto.SizeVarint(4<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.HomeAddress)))
n += len(x.HomeAddress)
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例14: _GcRule_OneofSizer
func _GcRule_OneofSizer(msg proto.Message) (n int) {
m := msg.(*GcRule)
// rule
switch x := m.Rule.(type) {
case *GcRule_MaxNumVersions:
n += proto.SizeVarint(1<<3 | proto.WireVarint)
n += proto.SizeVarint(uint64(x.MaxNumVersions))
case *GcRule_MaxAge:
s := proto.Size(x.MaxAge)
n += proto.SizeVarint(2<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *GcRule_Intersection_:
s := proto.Size(x.Intersection)
n += proto.SizeVarint(3<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *GcRule_Union_:
s := proto.Size(x.Union)
n += proto.SizeVarint(4<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例15: _ZoneServerMsg_OneofSizer
func _ZoneServerMsg_OneofSizer(msg proto.Message) (n int) {
m := msg.(*ZoneServerMsg)
// Msg
switch x := m.Msg.(type) {
case *ZoneServerMsg_ForWardZoneStartupMsg:
s := proto.Size(x.ForWardZoneStartupMsg)
n += proto.SizeVarint(1<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}