Skip to main content

SubgroupHeader

Struct SubgroupHeader 

Source
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 — 0x00 it is zero, 0x02 it is the Object ID of the first object on the stream and is not transmitted, 0x04 it is a field on the wire. 0x06 is 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

Source

pub fn has_extensions(&self) -> bool

Source

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.

Source

pub fn has_explicit_subgroup_id(&self) -> bool

Source

pub fn has_end_of_group(&self) -> bool

Source

pub fn has_priority(&self) -> bool

Source

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.

Source

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.

Source

pub fn decode(buf: &mut impl Buf) -> Result<Self, CodecError>

Trait Implementations§

Source§

impl Clone for SubgroupHeader

Source§

fn clone(&self) -> SubgroupHeader

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SubgroupHeader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for SubgroupHeader

Source§

impl PartialEq for SubgroupHeader

Source§

fn eq(&self, other: &SubgroupHeader) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SubgroupHeader

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.