Reputation: 33714
I can't find if there is possible to have char / byte type in proto.
I can see various types here:
but I can't find byte type and even int16 types there.
Upvotes: 32
Views: 37185
Reputation: 1062512
No, there is no fixed 1-byte type. Fixed length has 4 and 8 byte variants only. Most other numeric values are encoded as "varint"s, which is variable length depending on magnitude (and sign, but "zigzag" comes into play there). So you can store bytes with value 0-127 in one byte, and 128-255 in two bytes. 16-bit values will take between 1 and 3 bytes depending on magnitude (and sign /zigzag etc).
For multiples, there is "bytes" for the 8-bit version, and "packed" for the rest; this avoids the cost of a field-header per value.
Upvotes: 33