Skip to main content

Module data_stream

Module data_stream 

Source
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 Section 10.4.2 and draft-17 Section 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.

Re-exportsΒ§

use bytes::Buf; πŸ”’
use bytes::BufMut; πŸ”’
use super::types::ObjectStatus; πŸ”’
use crate::error::CodecError; πŸ”’
use crate::object_properties::ObjectProperty; πŸ”’
use crate::object_properties::PropertyValue; πŸ”’
use crate::varint::Moqt17 as Wire; πŸ”’
use crate::varint::VarInt; πŸ”’

StructsΒ§

DatagramHeader
FetchGaps
The Prior Group ID Gap and Prior Object ID Gap conditions of draft-17 Section 11.7 and draft-17 Section 11.8 that one fetch stream shows.
FetchHeader
FetchObject
One frame from a FETCH stream with the fields its Serialization Flags left off the wire filled in from the frames before it.
FetchObjectHeader
One object on a draft-17 fetch stream, without its payload.
FetchObjectReader
Resolves the elided fields of the frames on one FETCH stream.
FetchObjectWriter
Re-encodes resolved fetch frames onto one FETCH stream.
PriorGaps
The Prior Group ID Gap and Prior Object ID Gap one Object carries.
SubgroupHeader
SubgroupObject
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. Use SubgroupObjectReader to encode/decode.
SubgroupObjectMeta
The framing of one draft-17 subgroup object, without its payload.
SubgroupObjectReader

EnumsΒ§

EndOfRange
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.
PayloadPermission
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 0b00X0XXXX written 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. Mode 0x00, 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.
PRIOR_GROUP_ID_GAP
Prior Group ID Gap, Object Property Type 0x3C (Section 11.7).
PRIOR_OBJECT_ID_GAP
Prior Object ID Gap, Object Property Type 0x3E (Section 11.8).
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 0b00X1XXXX written 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Β§

collect_gaps πŸ”’
datagram_type_error πŸ”’
Which failure a leading datagram Type that is not one a reader wants is.
datagram_type_is_valid πŸ”’
Whether datagram_type is 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 buf past len bytes 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 raw sits 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_type is 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.