Expand description
Draft-16 data stream header encoding and decoding.
Draft-16 subgroup type-byte flag layout:
& 0x01: extensions present on objects& 0x06: SUBGROUP_ID_MODE. Section 10.4.2: “The SUBGROUP_ID_MODE field (bits 1-2, mask 0x06) is a two-bit field that determines the encoding of the Subgroup ID. To extract this value, perform a bitwise AND with mask 0x06 and right-shift by 1 bit”. Mode 0 puts no Subgroup ID on the wire and it is zero, mode 1 takes it from the first object, mode 2 reads it as a field after the Group ID, and mode 3 is reserved& 0x08: end-of-group marker& 0x20: no publisher_priority (0x30+ types)
Because the mode is one field and not two independent bits, the three
carriers are mutually exclusive: a Type setting both 0x02 and 0x04 names
the reserved mode, not two carriers at once. This module described those bits
separately and read them separately, which let a single Type answer to two
carriers.
Draft-15 spells the same three carriers out of the same two bits, as a pair
of table columns rather than a named field, and the two drafts end up
admitting the same twenty-four Types — draft-16 by excluding the reserved
mode from the ranges 0x10-0x1F and 0x30-0x3F, draft-15 by listing
them.
Draft-16 datagram type-byte flag layout:
0x01: extensions present (byte-length-prefixed blob)0x02: end-of-group0x04: no object_id (object_id = 0 implied)0x08: default priority (priority omitted, inherited)0x20: status datagram (carries object_status instead of payload)
Draft-16 fetch objects are framed differently again: a per-object
Serialization Flags varint decides which of Group ID, Subgroup ID, Object ID,
Priority and Extensions are on the wire, and a field left off is taken from
the object before it. See FetchObjectHeader for the flag layout and
FetchObjectReader for the inheritance. A fetch object carries no Object
Status at all — draft-16 Section 10.2.1.1 puts that field on subscription
deliveries only.
Extension headers in draft-16 are byte-length-prefixed opaque blobs (not count-prefixed as in draft-14).
Structs§
- Datagram
Header - Fetch
Header - Fetch
Object Header - One Object as it is framed on a draft-16 fetch stream, before any field is resolved against the Object before it.
- Fetch
Object Location - One fetch object’s Location and priority, with every field the flags left off the wire filled in from the Object before it.
- Fetch
Object Reader - Stateful resolver for the Objects on one draft-16 fetch stream.
- Fetch
Object Writer - Re-encodes resolved fetch Objects onto one FETCH stream.
- Subgroup
Header - Subgroup
Object - One object within a draft-16 subgroup stream with its Object ID
already resolved from the delta encoding. See
SubgroupObjectReaderfor stateful encode/decode. - Subgroup
Object Meta - The framing of one draft-16 subgroup object, without its payload.
- Subgroup
Object Reader - Stateful reader/writer for draft-16 subgroup objects. Mirrors the draft-15 semantics (delta-encoded object IDs and header-typed extension presence).
Enums§
- Fetch
EndOf Range - The two Serialization Flags values draft-16 gives a meaning of their own instead of reading as a bit field, from Section 10.4.4 Table 4.
- Fetch
Subgroup Mode - How an Object on a draft-16 fetch stream states its Subgroup ID.
- Payload
Permission - Whether an Object carrying a given status is allowed a non-empty payload.
Constants§
- DATAGRAM_
END_ 🔒OF_ GROUP_ BIT - The END_OF_GROUP bit of a datagram Type.
- DATAGRAM_
FORM_ 🔒FORBIDDEN_ BITS - Bits 4, 6 and 7, which the datagram’s 0b00X0XXXX form leaves clear.
- DATAGRAM_
STATUS_ 🔒BIT - The STATUS bit of a datagram Type.
- FETCH_
STREAM_ 🔒TYPE - The unidirectional stream Type draft-16 Section 10.4.4 gives a fetch stream.
- SUBGROUP_
BASE_ 🔒BIT - Bit 4, which every subgroup header Type sets.
- SUBGROUP_
FORM_ 🔒FORBIDDEN_ BITS - Bits 6 and 7, which the subgroup header’s 0b00X1XXXX form leaves clear.
- SUBGROUP_
ID_ 🔒MODE_ MASK - Bits 1-2, the SUBGROUP_ID_MODE field.
- SUBGROUP_
ID_ 🔒MODE_ RESERVED - The SUBGROUP_ID_MODE value draft-16 reserves, once the mask is applied and the field shifted down.
Functions§
- datagram_
type_ 🔒is_ status_ end_ of_ group - Whether
rawsits inside the datagram form but sets STATUS and END_OF_GROUP together — the first of Section 10.3.1’s two lists. - datagram_
type_ 🔒is_ valid - Whether
rawis a datagram Type draft-16 admits. - datagram_
type_ 🔒refusal - The refusal a datagram Type deserves, as a plain function so
wide_type_refusalcan take it. - decoded_
status 🔒 - Turn a wire Object Status code into the status draft-16 gives it, refusing any code the draft does not assign.
- extensions_
permitted_ 🔒at - Whether an Object at
statusis allowed to carryextensions_lenbytes of extension headers. - skip 🔒
- Advance
bufpastlenbytes without copying them. - stream_
type_ 🔒error - Which failure a leading unidirectional stream Type that is not the one a reader wants is.
- subgroup_
type_ 🔒is_ reserved_ mode - Whether
rawsits inside the subgroup form but names the reserved SUBGROUP_ID_MODE — the first of Section 10.4.2’s two lists. - subgroup_
type_ 🔒is_ valid - Whether
rawis a subgroup Type draft-16 admits: inside the form, and not the reserved SUBGROUP_ID_MODE. - validate_
datagram_ 🔒type - Refuse a datagram Type value draft-16 Section 10.3.1 lists as invalid.
- validate_
subgroup_ 🔒type - Refuse a subgroup header Type value draft-16 Section 10.4.2 lists as invalid.
- wide_
type_ 🔒refusal - Refuse a Type field spelled in more than one byte, before anything narrows it to a byte.