1.3 Wiretypes
The wire-stream consists of six primitive payload types, two of which have been deprecated. A primitive in the wire-stream is a multi-byte string that provides three pieces of information: a wire-type, a user-specified tag, and the raw payload. Except for the tag and its wire-type, protobuf payloads are not instantaneously recognizable because the wire-stream contains no payload type information. The interpreter uses the tag to associate the raw payload with a local host type specified by the template. Hence, the message can only be properly decoded using the template that was used to encode it. Note also that the primitive is interpreted according to the needs of a local host. Local word-size and endianness are dealt with at this level.
The following table shows the association between various "host types" used by several peer languages, and the primitives used in the wire-stream:
Prolog Wirestream C++ Java Notes double fixed64 double double integer64 fixed64 int64 long float fixed32 float float integer32 fixed32 int32 int integer varint int32/64 int/long 1, 2 unsigned varint uint32/64 int/long 2, 3 boolean varint bool boolean 2 enum varint int int 2 atom length delimited string String 4 codes length delimited string ByteString utf8_codes length delimited string ByteString 4 string length delimited string String 4
Notes:
- Encoded using a compression technique known as zig-zagging.
- Encoded as a modulo 128 string. Its length is proprotional to its magnitude. The intrinsic word length is decoupled between parties.
- Prolog's unbounded integer may be expressed as unsigned. This is not portable across languages.
- Encoded as UTF8 in the wire-stream.