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>,
}

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

Whether SUBGROUP_ID_MODE is 1: the Subgroup ID is the first object’s Object ID and is not transmitted on the wire.

Reads the two bits as the one field Section 10.4.2 defines, rather than as the single bit 0x02. The single-bit reading answered true for a Type naming the reserved mode 3, where 0x02 and 0x04 are both set — so this predicate and Self::has_explicit_subgroup_id answered true together, for a state one two-bit field cannot be in.

Source

pub fn has_explicit_subgroup_id(&self) -> bool

Whether SUBGROUP_ID_MODE is 2: an explicit Subgroup ID field follows the Group ID.

Self::decode refuses the reserved mode before reading any field, so on a decoded header this agrees with the single-bit 0x04 reading it replaces. The two differ only on a header built by hand, which is the only way to hold a reserved-mode Type at all.

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)

Serialize the header exactly as its Type byte describes it.

Infallible, and so willing to write a Type draft-16 Section 10.4.2 tells an endpoint to reject — including a reserved-mode Type this module’s own Self::decode refuses to read back. Prefer Self::encode_checked, which refuses those Types instead.

A reserved-mode Type gets no Subgroup ID field, because mode 3 defines none: the draft says what the other three modes put on the wire and nothing about this one. Writing the field there was an artifact of reading 0x04 on its own, and it disagreed with every neighbouring draft — 15, 17, 18 and 19 all leave it off.

Source

pub fn encode_checked(&self, buf: &mut impl BufMut) -> Result<(), CodecError>

Serialize the header, refusing a Type value draft-16 forbids.

Errors with CodecError::InvalidField for exactly the Types Section 10.4.2 lists as invalid — the same set Self::decode refuses — before any byte is written, so a refused header leaves buf untouched.

The check belongs on this side as well because the two halves would otherwise disagree about which streams exist: a reserved-mode header written by Self::encode cannot be read back by Self::decode, and a codec used to rewrite captured traffic would emit a stream it could not then parse.

Source

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

Decode a subgroup header, Type field included.

A Type spelled in more than one byte is refused before it is narrowed, by wide_type_refusal. Every Type draft-16 assigns fits a single byte, so a wider spelling is either a Type this draft does not have or a non-minimal spelling of one it does, and both have to be refused rather than truncated into a Type that happens to be valid.

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.