Expand description
Draft-17 data stream header encoding and decoding.
Subgroup header type byte: 0b00X1XXXX (bit 4 always set)
- bit 0 (0x01): PROPERTIES
- bits 1-2 (0x06): SUBGROUP_ID_MODE (0=zero, 1=first_obj, 2=explicit, 3=reserved)
- bit 3 (0x08): END_OF_GROUP
- bit 5 (0x20): DEFAULT_PRIORITY (no priority byte)
Datagram type byte: 0b00X0XXXX (bit 4 always 0)
- bit 0 (0x01): PROPERTIES
- bit 1 (0x02): END_OF_GROUP
- bit 2 (0x04): ZERO_OBJECT_ID (object_id=0, field omitted)
- bit 3 (0x08): DEFAULT_PRIORITY (no priority byte)
- bit 5 (0x20): STATUS (status byte replaces payload)
Neither range is fully populated. Draft-17 Sections 10.4.2 and 10.3.1 each
close with a list of type values an endpoint “MUST close the session with a
PROTOCOL_VIOLATION” on receiving, and the two figures spell the surviving
values out: 0x10..0x15 / 0x18..0x1D / 0x30..0x35 / 0x38..0x3D for a
subgroup header, 0x00..0x0F / 0x20..0x21 / 0x24..0x25 / 0x28..0x29 / 0x2C..0x2D for a datagram. Both decoders refuse everything else, so a
header this module hands back always describes a framing the draft defines.
Fetch header: stream type 0x05 + request_id, followed by objects whose
fields are named by a Serialization Flags varint rather than all being
present — see FetchObjectHeader.
Structs§
- Datagram
Header - Fetch
Header - Fetch
Object - One frame from a FETCH stream with the fields its Serialization Flags left off the wire filled in from the frames before it.
- Fetch
Object Header - One object on a draft-17 fetch stream, without its payload.
- Fetch
Object Reader - Resolves the elided fields of the frames on one FETCH stream.
- Fetch
Object Writer - Re-encodes resolved fetch frames onto one FETCH stream.
- Subgroup
Header - Subgroup
Object - One object within a draft-17 subgroup stream. Object IDs are
delta-encoded and the presence of a “properties” block (the
draft-17 equivalent of extension headers) is determined by the
PROPERTIES bit on the enclosing
SubgroupHeader. UseSubgroupObjectReaderto encode/decode. - Subgroup
Object Meta - The framing of one draft-17 subgroup object, without its payload.
- Subgroup
Object Reader
Enums§
- EndOf
Range - The two Serialization Flags values that mark a range of Objects rather than carrying one, from draft-17 Section 10.4.4 Table 6 and Section 10.4.4.2.
- Payload
Permission - Whether an object carrying a given status is allowed a non-empty payload.
Constants§
- DATAGRAM_
DEFAULT_ 🔒PRIORITY_ BIT - DATAGRAM_
END_ 🔒OF_ GROUP_ BIT - DATAGRAM_
FORM_ 🔒MASK - The bits a datagram type must fix: 7, 6 and 4 all clear. That is the form
0b00X0XXXXwritten as a mask, leaving bit 5 and the low nibble free. - DATAGRAM_
PROPERTIES_ 🔒BIT - DATAGRAM_
STATUS_ 🔒BIT - DATAGRAM_
ZERO_ 🔒OBJECT_ ID_ BIT - FETCH_
DATAGRAM_ 🔒BIT - The object was forwarded as a datagram and has no Subgroup ID; the two least significant bits are to be ignored.
- FETCH_
END_ 🔒OF_ NON_ EXISTENT_ RANGE - Serialization Flags
0x8C, End of Non-Existent Range. - FETCH_
END_ 🔒OF_ UNKNOWN_ RANGE - Serialization Flags
0x10C, End of Unknown Range. - FETCH_
FLAGS_ 🔒BIT_ FORM_ MAX - The largest Serialization Flags value read as a set of bits. Draft-17 Section 10.4.4: “When less than 128, the bits represent flags described below.”
- FETCH_
GROUP_ 🔒ID_ BIT - Group ID field present; clear means the prior object’s Group ID.
- FETCH_
OBJECT_ 🔒ID_ BIT - Object ID field present; clear means the prior object’s ID plus one.
- FETCH_
PRIORITY_ 🔒BIT - Priority field present; clear means the prior object’s priority.
- FETCH_
PROPERTIES_ 🔒BIT - Properties field present.
- FETCH_
STREAM_ 🔒TYPE - FETCH_
SUBGROUP_ 🔒MODE_ EXPLICIT - SUBGROUP mode
0x03: an explicit Subgroup ID field is present. - FETCH_
SUBGROUP_ 🔒MODE_ MASK - SUBGROUP mode, the two least significant Serialization Flags bits (draft-17 Section 10.4.4.1, Table 7).
- FETCH_
SUBGROUP_ 🔒MODE_ PRIOR - SUBGROUP mode
0x01: the Subgroup ID is the prior object’s. Mode0x00, the remaining value, fixes the Subgroup ID at zero and needs no constant — nothing tests for it. - FETCH_
SUBGROUP_ 🔒MODE_ PRIOR_ PLUS_ ONE - SUBGROUP mode
0x02: the Subgroup ID is the prior object’s plus one. - SETUP_
STREAM_ 🔒TYPE - The unidirectional stream Type draft-17 Section 9.4 gives the control stream.
- SUBGROUP_
BASE_ 🔒BIT - SUBGROUP_
DEFAULT_ 🔒PRIORITY_ BIT - SUBGROUP_
END_ 🔒OF_ GROUP_ BIT - SUBGROUP_
FORM_ 🔒MASK - The bits a subgroup header type must fix: 7 and 6 clear, 4 set. That is the
form
0b00X1XXXXwritten as a mask, leaving bit 5 and the low nibble free. - SUBGROUP_
ID_ 🔒MODE_ MASK - SUBGROUP_
ID_ 🔒MODE_ RESERVED - SUBGROUP_ID_MODE
0b11, the value draft-17 reserves. - SUBGROUP_
PROPERTIES_ 🔒BIT
Functions§
- datagram_
type_ 🔒error - Which failure a leading datagram Type that is not one a reader wants is.
- datagram_
type_ 🔒is_ valid - Whether
datagram_typeis one of the datagram types draft-17 defines. - decoded_
status 🔒 - Turn a wire Object Status code into an
ObjectStatus, refusing one draft-17 does not assign. - fetch_
flags_ 🔒are_ defined - Whether draft-17 defines this Serialization Flags value.
- fetch_
has_ 🔒group_ id - fetch_
has_ 🔒object_ id - fetch_
has_ 🔒priority - fetch_
has_ 🔒properties - fetch_
has_ 🔒subgroup_ id - Whether an explicit Subgroup ID field follows the Group ID.
- 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 the two lists quoted above. - subgroup_
type_ 🔒is_ valid - Whether
header_typeis one of the subgroup header types draft-17 defines. - wide_
type_ 🔒refusal - Refuse a Type field spelled in more than one byte, before anything narrows it to a byte.