wire / wire-format / capnproto

Cap'n Proto (zero-copy serialization)

Cap'n Proto is a zero-copy serialization format by the creator of Protocol Buffers. A Cap'n Proto message: segment table (number of segments + segment sizes), then segments (each a sequence of 64-bit words). Pointers (struct, list, text, data) are 64-bit values with type, offset, and size. Structs are fixed-size with a data section and pointer section. Lists can be of primitives, pointers, or structs.

wire-format kind wire-format status standard verification verified tier B wire-format@1

aka: Cap'n Proto (zero-copy serialization)

wire format

spec: Cap'n Proto (capnproto.org)

Cap'n Proto is a zero-copy serialization format by the creator of Protocol Buffers. A Cap'n Proto message: segment table (number of segments + segment sizes), then segments (each a sequence of 64-bit words). Pointers (struct, list, text, data) are 64-bit values with type, offset, and size. Structs are fixed-size with a data section and pointer section. Lists can be of primitives, pointers, or structs.

fieldsizemeaning
Segment count - 14 bytes (uint32)Number of segments minus 1.
Padding4 bytesZero padding to 8-byte alignment.
Segment sizes4 bytes each (uint32)Size of each segment in 8-byte words.
Segment datavariable64-bit words: struct pointers, list pointers, text/data pointers, and primitive values.
Struct pointer8 bytesType (2 bits) + offset (30 bits) + data size (16 bits) + pointer count (16 bits).
List pointer8 bytesType (2 bits) + offset (30 bits) + element size (3 bits) + element count (29 bits).

example:

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Cap'n Proto: 1 segment, 0 words (empty message)


provenance

agent: curl -H 'accept: application/json' wire.phall.io/wire-format/capnproto or /wire-format/capnproto.json