wire / wire-format / thrift-binary
Apache Thrift's binary protocol encodes each field as: 1-byte type, 2-byte field ID (big-endian), then the value. A struct is a sequence of fields terminated by a STOP (type 0). Types: 0 STOP, 1 VOID, 2 BOOL, 3 BYTE, 4 I16, 5 I32, 6 I64, 7 DOUBLE, 8 STRING (4-byte length + bytes), 9 MAP, 10 SET, 11 LIST, 12 STRUCT, 13 UUID (16 bytes).
aka: Thrift binary protocol
spec: Apache Thrift
Apache Thrift's binary protocol encodes each field as: 1-byte type, 2-byte field ID (big-endian), then the value. A struct is a sequence of fields terminated by a STOP (type 0). Types: 0 STOP, 1 VOID, 2 BOOL, 3 BYTE, 4 I16, 5 I32, 6 I64, 7 DOUBLE, 8 STRING (4-byte length + bytes), 9 MAP, 10 SET, 11 LIST, 12 STRUCT, 13 UUID (16 bytes).
| field | size | meaning |
|---|---|---|
| Field type | 1 byte | 0 STOP, 1 VOID, 2 BOOL, 3 BYTE, 4 I16, 5 I32, 6 I64, 7 DOUBLE, 8 STRING, 9 MAP, 10 SET, 11 LIST, 12 STRUCT, 13 UUID. |
| Field ID | 2 bytes (int16, big-endian) | Field identifier from the Thrift IDL. |
| Value | variable | Type-specific encoding (see below). |
| BOOL | 1 byte | 0x00 = false, 0x01 = true. |
| I16/I32/I64 | 2/4/8 bytes | Signed integer, big-endian. |
| DOUBLE | 8 bytes | IEEE 754 double, big-endian. |
| STRING/BINARY | 4 bytes (int32) + data | Length-prefixed UTF-8 string or binary blob. |
| MAP | variable | 1-byte key type, 1-byte value type, 4-byte count, then key-value pairs. |
| LIST/SET | variable | 1-byte element type, 4-byte count, then elements. |
| STRUCT | variable | Nested fields (same format), terminated by STOP (0x00 type + 0x0000 field ID). |
example:
00 00 00
Empty struct: STOP (type 0, field ID 0)
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/thrift-binary
or /wire-format/thrift-binary.json