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
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
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.
Sourcepub fn has_explicit_subgroup_id(&self) -> bool
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.
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)
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.
Sourcepub fn encode_checked(&self, buf: &mut impl BufMut) -> Result<(), CodecError>
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.
Sourcepub fn decode(buf: &mut impl Buf) -> Result<Self, CodecError>
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
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