pub struct SubgroupHeader {
pub header_type: u8,
pub track_alias: VarInt,
pub group_id: VarInt,
pub subgroup_id: VarInt,
pub publisher_priority: Option<u8>,
}Expand description
Subgroup stream header for draft-15.
Draft-15 Section 10.4.2 Table 6 assigns twenty-four stream types, built from
a base of 0x10 or 0x30 and three independent fields:
& 0x01: extensions present on objects& 0x06: how the Subgroup ID is carried —0x00it is zero,0x02it is the Object ID of the first object on the stream and is not transmitted,0x04it is a field on the wire.0x06is not a row& 0x08: the last object on the stream ends its group& 0x20: no publisher priority; the object inherits the one the subscription established
These two bits are read together, not as two independent flags, and the
table is what settles it: it gives them as a pair of columns, Subgroup ID
Field Present and Subgroup ID Value, and no row carries both a present
field and a value taken from the first object. Reading 0x02 as an
end-of-group marker — which is what this did — answers the wrong question
in both directions: a real end-of-group stream (0x18-0x1D,
0x38-0x3D) reports false, and a first-object stream (0x12, 0x13)
reports true. Neither is a framing error, so nothing downstream notices.
Draft-16 later folds the same three choices into a named SUBGROUP_ID_MODE
field with a fourth, reserved value. Draft-15 has no such name and no such
value: 0x16, 0x17, 0x1E, 0x1F, 0x36, 0x37, 0x3E and 0x3F
are absent from Table 6 rather than reserved by it, and the word does not
appear here in that sense at all. The two drafts agree on every byte and
differ only in how they say why, so borrowing the later vocabulary reads
as though draft-15 states something it does not.
Fields§
§header_type: u8§track_alias: VarInt§group_id: VarInt§subgroup_id: VarInt§publisher_priority: Option<u8>Implementations§
Source§impl SubgroupHeader
impl SubgroupHeader
pub fn has_extensions(&self) -> bool
Sourcepub fn subgroup_id_from_first_object(&self) -> bool
pub fn subgroup_id_from_first_object(&self) -> bool
When set, the Subgroup ID is the Object ID of the first object on the
stream and is not transmitted. The 0x02 row of the 0x06 bits.
pub fn has_explicit_subgroup_id(&self) -> bool
pub fn has_end_of_group(&self) -> bool
pub fn has_priority(&self) -> bool
Sourcepub fn encode(&self, buf: &mut impl BufMut)
pub fn encode(&self, buf: &mut impl BufMut)
Encode the header, writing whichever fields the type byte announces.
Field presence follows header_type, because that is what the peer
reads. A publisher_priority of None under a type whose 0x20 bit is
clear writes a zero rather than dropping the byte: omitting it would
leave the peer reading the first object’s Object ID Delta as a priority
and desync the whole stream. Use encode_checked
to be told about the disagreement instead of having it papered over.
Sourcepub fn encode_checked(&self, buf: &mut impl BufMut) -> Result<(), CodecError>
pub fn encode_checked(&self, buf: &mut impl BufMut) -> Result<(), CodecError>
Encode, refusing a header whose fields disagree with its own type byte.
encode is driven by header_type and
decode reads the same byte, so the two agree on the
wire whatever the struct holds —
but a caller that sets publisher_priority beside a type whose 0x20
bit is set, or leaves it None beside one whose bit is clear, has built
a header that does not mean what it says. The fetch object writer
already refuses that shape; this is the same check one layer up.
pub fn decode(buf: &mut impl Buf) -> Result<Self, CodecError>
Trait Implementations§
Source§impl Clone for SubgroupHeader
impl Clone for SubgroupHeader
Source§fn clone(&self) -> SubgroupHeader
fn clone(&self) -> SubgroupHeader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more