I have an encoded binary as follows:
0a 16 0a 06 72 63 6e 33 31 72 12 0a 65 37 36 30 34 32 33 35 32 37 1a 00
20 01 2a 06 34 34 38 37 38
I am not sure how to write the proto file reflecting the binary. I know the message contents.
1. First two bytes indicate an embedded message with 22 bytes in length.
2. Inside the embedded message there are three fields (three strings).
3. Then the rest of the message with two fields.
How to write the .proto file to reflect the above binary ?
message UserInfo
{
required string username = 1;
required string usserId = 2;
optional string extraInfo= 3;
}
message SendUserRequest
{
required UserInfo uinfo = 1;
...
}
Sorry, but this isn't what Protobuf is for. Protobuf can only decode Protobuf format; it cannot match arbitrary ad-hoc byte formats.
EDIT: I misunderstood the question. Sometimes people think Protobufs can describe arbitrary binary, and the exact bytes given were rejected by
protoc --decode_raw
, but it turns out there was a missing byte. I added a better answer above.