Primitives

The fundamental wire values used to serialize packet fields.

Wire formats

Boolean

boolean1 byte

Written as one byte: 0 for false and 1 for true. Readers accept any nonzero byte as true.

Example: trueFirst byte on left
byte 00000 00010x01

Signed integer

int81 byte

Raw two's-complement signed integer bytes.

Example: -42First byte on left
byte 01101 01100xD6
int162 bytes

Raw two's-complement signed integer bytes in native byte order.

Example: -42First byte on left
byte 01101 01100xD6
byte 11111 11110xFF
int324 bytes

Raw two's-complement signed integer bytes in native byte order. Big Endian reverses the byte order.

Example: -42First byte on left
byte 01101 01100xD6
byte 11111 11110xFF
byte 21111 11110xFF
byte 31111 11110xFF
int648 bytes

Raw two's-complement signed integer bytes in native byte order.

Example: -42First byte on left
byte 01101 01100xD6
byte 11111 11110xFF
byte 21111 11110xFF
byte 31111 11110xFF
byte 41111 11110xFF
byte 51111 11110xFF
byte 61111 11110xFF
byte 71111 11110xFF
varint321-5 bytes

ZigZag-encoded, then written as base-128 groups with the high bit indicating continuation.

Example: 64First byte on left
group 0, more1000 00000x80
group 1, final0000 00010x01
varint641-10 bytes

ZigZag-encoded, then written as base-128 groups with the high bit indicating continuation.

Example: 64First byte on left
group 0, more1000 00000x80
group 1, final0000 00010x01

Unsigned integer

uint81 byte

Raw unsigned integer bytes.

Example: 42First byte on left
byte 00010 10100x2A
uint162 bytes

Raw unsigned integer bytes in native byte order.

Example: 300First byte on left
byte 00010 11000x2C
byte 10000 00010x01
uint324 bytes

Raw unsigned integer bytes in native byte order.

Example: 300First byte on left
byte 00010 11000x2C
byte 10000 00010x01
byte 20000 00000x00
byte 30000 00000x00
uint648 bytes

Raw unsigned integer bytes in native byte order.

Example: 300First byte on left
byte 00010 11000x2C
byte 10000 00010x01
byte 20000 00000x00
byte 30000 00000x00
byte 40000 00000x00
byte 50000 00000x00
byte 60000 00000x00
byte 70000 00000x00
varuint321-5 bytes

Written as base-128 groups with the high bit indicating that another byte follows.

Example: 255First byte on left
group 0, more1111 11110xFF
group 1, final0000 00010x01
varuint641-10 bytes

Written as base-128 groups with the high bit indicating that another byte follows.

Example: 255First byte on left
group 0, more1111 11110xFF
group 1, final0000 00010x01

Floating point

float4 bytes

Raw 4-byte floating-point representation in native byte order.

Example: 3.5fFirst byte on left
byte 00000 00000x00
byte 10000 00000x00
byte 20110 00000x60
byte 30100 00000x40
double8 bytes

Raw 8-byte floating-point representation in native byte order.

Example: 3.5First byte on left
byte 00000 00000x00
byte 10000 00000x00
byte 20000 00000x00
byte 30000 00000x00
byte 40000 00000x00
byte 50000 00000x00
byte 60000 11000x0C
byte 70100 00000x40

Text

stringVariable

Raw string bytes prefixed by their byte length as a varuint32. The stream does not transcode or validate the byte encoding.

Example: "Hi"First byte on left
length0000 00100x02
data 'H'0100 10000x48
data 'i'0110 10010x69

Field annotations

Schema and serialization modifiers
Optional

A field is optional when it is not listed as required and does not define a default value.

An optional field starts with a boolean presence byte. 0x00 ends the field without a value; 0x01 is followed immediately by the value's normal wire encoding.

Example: empty optionalFirst byte on left
not present0000 00000x00
Example: optional uint8 42First byte on left
present0000 00010x01
uint8 value0010 10100x2A
Big Endian
Writes signed 32-bit integers with the most significant byte first.
Compression
Uses variable-length encoding for 32- and 64-bit integers and dynamic collection lengths.
No size compression
Writes a collection size without the normal variable-length size encoding.