Skip to main content

Module message_set

Module message_set 

Source
Expand description

MessageSet wire format helpers (legacy Google-internal encoding).

Enabled per-message via option message_set_wire_format = true on a proto2 message with no fields, only extensions N to M;. Each extension is encoded as a group at field 1 containing type_id = 2 (the extension’s field number) and message = 3 (the extension’s payload bytes):

tag(1, SGROUP) | tag(2, Varint) | <type_id> | tag(3, LD) | len | <payload> | tag(1, EGROUP)

instead of the regular tag(type_id, LD) | len | <payload>.

Storage is non-MessageSet: an unknown item with type_id = T and payload V is stored in UnknownFields as { number: T, data: LengthDelimited(V) }, not as a group. Decode unwraps the group into that form; encode rewraps it. This mirrors protobuf-go.

Constants§

ITEM_END_TAG
Field 1, wire type EndGroup (4): (1 << 3) | 4.
ITEM_START_TAG
Field 1, wire type StartGroup (3): (1 << 3) | 3.
MESSAGE_TAG
Field 3, wire type LengthDelimited (2): (3 << 3) | 2.
TYPE_ID_TAG
Field 2, wire type Varint (0): (2 << 3) | 0.

Functions§

item_encoded_len
Encoded length of one MessageSet Item wrapping payload_len bytes at extension field number.
merge_item
Parse one MessageSet Item group body (between SGROUP and EGROUP).