In protobuf, how would you serialize an array of char's, (u)int8_t or (u)int16_t? Should the message look like this:
message ArrayWithNotSupportedTypes
{
int32 type = 1;
string byte_stream = 2;
}
where type
could store some unique id of the element type stored in the array.
And then the byte_stream
is populated with contents of an array, where values are of one of the types above?
Also,I have seen that there is a type called bytes
in protobuf, that is translated to an std::string
in the corresponding grpc.pb.h files. Is there any advantage of choosing bytes
ahead of string
?