Protocol Buffers - Google's data interchange format (grpc依赖)
https://developers.google.com/protocol-buffers/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
238 lines
6.1 KiB
238 lines
6.1 KiB
syntax = "proto2"; |
|
|
|
package basic_test_proto2; |
|
|
|
import "google/protobuf/duration.proto"; |
|
import "google/protobuf/struct.proto"; |
|
import "google/protobuf/timestamp.proto"; |
|
import "google/protobuf/wrappers.proto"; |
|
|
|
message Foo { |
|
optional Bar bar = 1; |
|
repeated Baz baz = 2; |
|
} |
|
|
|
message Bar { |
|
optional string msg = 1; |
|
} |
|
|
|
message Baz { |
|
optional string msg = 1; |
|
} |
|
|
|
message TestMessage { |
|
optional int32 optional_int32 = 1; |
|
optional int64 optional_int64 = 2; |
|
optional uint32 optional_uint32 = 3; |
|
optional uint64 optional_uint64 = 4; |
|
optional bool optional_bool = 5; |
|
optional float optional_float = 6; |
|
optional double optional_double = 7; |
|
optional string optional_string = 8; |
|
optional bytes optional_bytes = 9; |
|
optional TestMessage2 optional_msg = 10; |
|
optional TestEnum optional_enum = 11; |
|
|
|
repeated int32 repeated_int32 = 12; |
|
repeated int64 repeated_int64 = 13; |
|
repeated uint32 repeated_uint32 = 14; |
|
repeated uint64 repeated_uint64 = 15; |
|
repeated bool repeated_bool = 16; |
|
repeated float repeated_float = 17; |
|
repeated double repeated_double = 18; |
|
repeated string repeated_string = 19; |
|
repeated bytes repeated_bytes = 20; |
|
repeated TestMessage2 repeated_msg = 21; |
|
repeated TestEnum repeated_enum = 22; |
|
} |
|
|
|
message TestMessage2 { |
|
optional int32 foo = 1; |
|
} |
|
|
|
message TestMessageDefaults { |
|
optional int32 optional_int32 = 1 [default = 1]; |
|
optional int64 optional_int64 = 2 [default = 2]; |
|
optional uint32 optional_uint32 = 3 [default = 3]; |
|
optional uint64 optional_uint64 = 4 [default = 4]; |
|
optional bool optional_bool = 5 [default = true]; |
|
optional float optional_float = 6 [default = 6]; |
|
optional double optional_double = 7 [default = 7]; |
|
optional string optional_string = 8 [default = "Default Str"]; |
|
optional bytes optional_bytes = 9 [default = "\xCF\xA5s\xBD\xBA\xE6fubar"]; |
|
optional TestMessage2 optional_msg = 10; |
|
optional TestNonZeroEnum optional_enum = 11 [default = B2]; |
|
} |
|
|
|
enum TestEnum { |
|
Default = 0; |
|
A = 1; |
|
B = 2; |
|
C = 3; |
|
v0 = 4; |
|
} |
|
|
|
enum TestNonZeroEnum { |
|
A2 = 1; |
|
B2 = 2; |
|
C2 = 3; |
|
} |
|
|
|
message TestEmbeddedMessageParent { |
|
optional TestEmbeddedMessageChild child_msg = 1; |
|
optional int32 number = 2; |
|
|
|
repeated TestEmbeddedMessageChild repeated_msg = 3; |
|
repeated int32 repeated_number = 4; |
|
} |
|
|
|
message TestEmbeddedMessageChild { |
|
optional TestMessage sub_child = 1; |
|
} |
|
|
|
message Recursive1 { |
|
optional Recursive2 foo = 1; |
|
} |
|
|
|
message Recursive2 { |
|
optional Recursive1 foo = 1; |
|
} |
|
|
|
message MapMessageWireEquiv { |
|
repeated MapMessageWireEquiv_entry1 map_string_int32 = 1; |
|
repeated MapMessageWireEquiv_entry2 map_string_msg = 2; |
|
} |
|
|
|
message MapMessageWireEquiv_entry1 { |
|
optional string key = 1; |
|
optional int32 value = 2; |
|
} |
|
|
|
message MapMessageWireEquiv_entry2 { |
|
optional string key = 1; |
|
optional TestMessage2 value = 2; |
|
} |
|
|
|
message OneofMessage { |
|
oneof my_oneof { |
|
string a = 1; |
|
int32 b = 2; |
|
TestMessage2 c = 3; |
|
TestEnum d = 4; |
|
} |
|
} |
|
|
|
message Wrapper { |
|
optional google.protobuf.DoubleValue double = 1; |
|
optional google.protobuf.FloatValue float = 2; |
|
optional google.protobuf.Int32Value int32 = 3; |
|
optional google.protobuf.Int64Value int64 = 4; |
|
optional google.protobuf.UInt32Value uint32 = 5; |
|
optional google.protobuf.UInt64Value uint64 = 6; |
|
optional google.protobuf.BoolValue bool = 7; |
|
optional google.protobuf.StringValue string = 8; |
|
optional google.protobuf.BytesValue bytes = 9; |
|
optional string real_string = 100; |
|
oneof a_oneof { |
|
string string_in_oneof = 10; |
|
} |
|
|
|
// Repeated wrappers don't really make sense, but we still need to make sure |
|
// they work and don't crash. |
|
repeated google.protobuf.DoubleValue repeated_double = 11; |
|
repeated google.protobuf.FloatValue repeated_float = 12; |
|
repeated google.protobuf.Int32Value repeated_int32 = 13; |
|
repeated google.protobuf.Int64Value repeated_int64 = 14; |
|
repeated google.protobuf.UInt32Value repeated_uint32 = 15; |
|
repeated google.protobuf.UInt64Value repeated_uint64 = 16; |
|
repeated google.protobuf.BoolValue repeated_bool = 17; |
|
repeated google.protobuf.StringValue repeated_string = 18; |
|
repeated google.protobuf.BytesValue repeated_bytes = 19; |
|
|
|
// Wrappers in oneofs don't make sense, but we still need to make sure they |
|
// work and don't crash. |
|
oneof wrapper_oneof { |
|
google.protobuf.DoubleValue oneof_double = 31; |
|
google.protobuf.FloatValue oneof_float = 32; |
|
google.protobuf.Int32Value oneof_int32 = 33; |
|
google.protobuf.Int64Value oneof_int64 = 34; |
|
google.protobuf.UInt32Value oneof_uint32 = 35; |
|
google.protobuf.UInt64Value oneof_uint64 = 36; |
|
google.protobuf.BoolValue oneof_bool = 37; |
|
google.protobuf.StringValue oneof_string = 38; |
|
google.protobuf.BytesValue oneof_bytes = 39; |
|
string oneof_plain_string = 101; |
|
} |
|
} |
|
|
|
message TimeMessage { |
|
optional google.protobuf.Timestamp timestamp = 1; |
|
optional google.protobuf.Duration duration = 2; |
|
} |
|
|
|
message Enumer { |
|
optional TestEnum optional_enum = 11; |
|
repeated TestEnum repeated_enum = 22; |
|
optional string a_const = 3; |
|
oneof a_oneof { |
|
string str = 100; |
|
TestEnum const = 101; |
|
} |
|
} |
|
|
|
message MyRepeatedStruct { |
|
repeated MyStruct structs = 1; |
|
} |
|
|
|
message MyStruct { |
|
optional string string = 1; |
|
optional google.protobuf.Struct struct = 2; |
|
} |
|
|
|
message TestExtensions { |
|
extensions 1 to max; |
|
} |
|
|
|
message TestNestedExtension { |
|
extend TestExtensions { |
|
optional string test = 1002 [default = "test"]; |
|
} |
|
} |
|
|
|
extend TestExtensions { |
|
optional int32 optional_int32_extension = 1; |
|
} |
|
|
|
// A message with message_set_wire_format. |
|
message TestMessageSet { |
|
option message_set_wire_format = true; |
|
|
|
extensions 4 to max; |
|
} |
|
|
|
message TestMessageSetExtension1 { |
|
extend TestMessageSet { |
|
optional TestMessageSetExtension1 message_set_extension = 98418603; |
|
} |
|
optional int32 i = 15; |
|
} |
|
|
|
message TestMessageSetExtension2 { |
|
extend TestMessageSet { |
|
optional TestMessageSetExtension2 message_set_extension = 98418634; |
|
} |
|
optional string str = 25; |
|
} |
|
|
|
message TestMessageSetExtension3 { |
|
optional string text = 35; |
|
} |
|
|
|
extend TestMessageSet { |
|
optional TestMessageSetExtension3 message_set_extension3 = 98418655; |
|
} |
|
|
|
message BadFieldNames { |
|
optional int32 dup = 1; |
|
optional int32 class = 2; |
|
}
|
|
|