Expand description
Draft-18 data stream header encoding and decoding.
Subgroup header type byte, draft-18 Section 11.4.2: the form is 0b0XX1XXXX, so bit 7 is clear and bit 4 is set, giving the ranges 0x10..0x1F, 0x30..0x3F, 0x50..0x5F, 0x70..0x7F.
- 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)
- bit 6 (0x40): FIRST_OBJECT (new in draft-18)
Datagram type byte, draft-18 Section 11.3.1: the form is 0b00X0XXXX, so bits 7, 6 and 4 are clear, giving the ranges 0x00..0x0F and 0x20..0x2F.
- 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)
Both sections then list the Type values inside those ranges that are
nonetheless invalid, and answer each with “MUST close the session with a
PROTOCOL_VIOLATION”: SUBGROUP_ID_MODE 0b11 on a stream header, and STATUS
together with END_OF_GROUP on a datagram. Both decoders refuse them, and so
do SubgroupHeader::encode_checked and DatagramHeader::encode_checked,
which write only what those decoders accept.
Fetch header: stream type 0x05 + request_id, then objects whose fields are
selected by a Serialization Flags varint and resolved against the object
before them (Section 11.4.4). FetchObjectHeader is the wire frame and
FetchObjectReader resolves it.
Padding, Section 11.5, is a stream type and a datagram type of its own —
PADDING_STREAM_TYPE and PADDING_DATAGRAM_TYPE — carrying no Objects.
Neither is a subgroup header or a datagram header, and this module’s
decoders refuse both rather than reading a padding frame’s leading bytes as
header fields.
Structs§
- Datagram
Header - Fetch
Header - Fetch
Object - One frame from a FETCH stream with its delta-encoded fields resolved.
- Fetch
Object Header - One frame on a draft-18 FETCH stream, exactly as it sits on the wire.
- Fetch
Object Reader - Resolves the delta-encoded 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-18 subgroup stream. Object IDs are
delta-encoded; whether a per-object “properties” block (the draft-18
equivalent of extension headers) is present depends on the PROPERTIES
bit on the enclosing
SubgroupHeader. UseSubgroupObjectReaderto encode/decode. - Subgroup
Object Meta - The framing of one draft-18 subgroup object, without its payload.
- Subgroup
Object Reader
Enums§
- EndOf
Range - Which End of Range a fetch frame marks, draft-18 Section 11.4.4.2.
- Group
Order - The order a FETCH response’s Groups arrive in, which decides how a Group ID Delta is applied.
- Payload
Permission - Whether an Object carrying a given status is permitted a non-empty payload.
Constants§
- DATAGRAM_
DEFAULT_ 🔒PRIORITY_ BIT - DATAGRAM_
END_ 🔒OF_ GROUP_ BIT - DATAGRAM_
FORM_ 🔒MASK - The bits the datagram form 0b00X0XXXX fixes to zero: bits 7, 6 and 4.
- DATAGRAM_
PROPERTIES_ 🔒BIT - DATAGRAM_
STATUS_ 🔒BIT - DATAGRAM_
ZERO_ 🔒OBJECT_ ID_ BIT - FETCH_
DATAGRAM_ 🔒BIT - Bit 0x40: the Object’s forwarding preference is Datagram, so it has no Subgroup ID and bits 0-1 are to be ignored.
- FETCH_
END_ 🔒OF_ NON_ EXISTENT_ RANGE - Serialization Flags value 0x8C: End of Non-Existent Range.
- FETCH_
END_ 🔒OF_ UNKNOWN_ RANGE - Serialization Flags value 0x10C: End of Unknown Range.
- FETCH_
FLAGS_ 🔒MAX - The largest Serialization Flags value that is a set of flags. Draft-18 Section 11.4.4: “When less than 128, the bits represent flags described below.”
- FETCH_
GROUP_ 🔒ID_ DELTA_ BIT - Bit 0x08: the Group ID Delta field is present.
- FETCH_
OBJECT_ 🔒ID_ DELTA_ BIT - Bit 0x04: the Object ID Delta field is present.
- FETCH_
PRIORITY_ 🔒BIT - Bit 0x10: the Publisher Priority field is present.
- FETCH_
PROPERTIES_ 🔒BIT - Bit 0x20: the Properties field is present.
- FETCH_
STREAM_ 🔒TYPE - FETCH_
SUBGROUP_ 🔒MODE_ MASK - Serialization Flags bits 0-1 (mask 0x03): how the Subgroup ID is encoded.
- FETCH_
SUBGROUP_ 🔒MODE_ PRESENT - Mode 0x03: the Subgroup ID field is present.
- FETCH_
SUBGROUP_ 🔒MODE_ PRIOR - Mode 0x01: the Subgroup ID is the prior Object’s.
- FETCH_
SUBGROUP_ 🔒MODE_ PRIOR_ PLUS_ ONE - Mode 0x02: the Subgroup ID is the prior Object’s plus one.
- FETCH_
SUBGROUP_ 🔒MODE_ ZERO - Mode 0x00: the Subgroup ID is zero.
- PADDING_
DATAGRAM_ TYPE - Datagram type for padding, draft-18 Section 11.5.2: “An endpoint MAY send a datagram with a type of 0x132B3E29 to send padding data. The datagram contains the type followed by zero or more bytes that MUST all be set to zero.”
- PADDING_
STREAM_ TYPE - Unidirectional stream type for padding, draft-18 Section 11.5.1: “An endpoint MAY open a unidirectional stream with a stream type of 0x132B3E28 to send padding data. The stream begins with the stream type, followed by zero or more bytes that MUST all be set to zero.”
- SETUP_
STREAM_ 🔒TYPE - The unidirectional stream Type draft-18 Section 10.3 gives the control stream.
- STATUS_
AND_ 🔒END_ OF_ GROUP - Both bits of the combination Section 11.3.1 forbids.
- SUBGROUP_
BASE_ 🔒BIT - SUBGROUP_
DEFAULT_ 🔒PRIORITY_ BIT - SUBGROUP_
END_ 🔒OF_ GROUP_ BIT - SUBGROUP_
FIRST_ 🔒OBJECT_ BIT - SUBGROUP_
FORM_ 🔒MASK - The bits the subgroup header form 0b0XX1XXXX fixes: bit 7 and bit 4.
- SUBGROUP_
FORM_ 🔒VALUE - The values the form fixes them to: bit 7 clear, bit 4 set.
- SUBGROUP_
ID_ 🔒MODE_ MASK - SUBGROUP_
ID_ 🔒MODE_ RESERVED - The SUBGROUP_ID_MODE value draft-18 reserves for future use.
- SUBGROUP_
PROPERTIES_ 🔒BIT
Functions§
- datagram_
type_ 🔒error - Which failure a leading datagram Type that is not one a reader wants is.
- datagram_
type_ 🔒is_ status_ end_ of_ group - Whether
rawsits inside the datagram form but sets STATUS and END_OF_GROUP together — the second of the two lists quoted above. - datagram_
type_ 🔒is_ valid - Whether
datagram_typeis a Type value draft-18 Section 11.3.1 allows on a datagram. - decoded_
status 🔒 - Turn a wire Object Status code into an
ObjectStatus, refusing one draft-18 does not assign. - payload_
permission_ 🔒of - The payload permission draft-18 Section 11.2.1.1 gives
status. - 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 second of the two lists quoted above. - subgroup_
type_ 🔒is_ valid - Whether
header_typeis a Type value draft-18 Section 11.4.2 allows on a subgroup stream. - wide_
type_ 🔒refusal - Refuse a Type field spelled in more than one byte, before anything narrows it to a byte.