Skip to main content

TrackNamespace

Struct TrackNamespace 

Source
pub struct TrackNamespace(pub Vec<Vec<u8>>);
Expand description

Track Namespace: an ordered set of Track Namespace Fields.

The permitted field count is not the same on every draft, so this type does not carry one. Section 2.4.1 “Track Naming” calls a Track Namespace “an ordered N-tuple of bytes where N can be between 1 and 32” on drafts 07 through 14, “an ordered set of between 1 and 32 Track Namespace Fields” on drafts 15 and 16, and “an ordered set of between 0 and 32 Track Namespace Fields” from draft-17 on. TrackNamespaceRules carries that answer per draft, along with the two rules Section 2.4.1 later adds about what a single field may contain.

Tuple Fields§

§0: Vec<Vec<u8>>

Implementations§

Source§

impl TrackNamespace

Source

pub fn encode(&self, buf: &mut impl BufMut)

Encode the namespace tuple into the buffer.

Source

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

Decode a namespace tuple under the rules every draft from 07 through 16 shares.

All ten of those drafts define a Track Namespace as “between 1 and 32” fields, so the count is held to that and nothing else is. This one reader serves all of them and cannot tell them apart, while the empty-field rule and the 4,096-byte namespace cap both arrive in draft-16: applying either here would refuse namespaces drafts 07 through 15 permit. A call site that knows which draft it is decoding reaches those rules through decode_rules with TrackNamespaceRules::for_draft.

Drafts 17 and later read namespaces through decode_moqt, which uses the other varint encoding.

Source

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

Decode a draft-16 Track Namespace that may have zero fields.

Draft-16 is the only draft before 17 with a namespace position that permits the empty set. Its NAMESPACE and NAMESPACE_DONE carry “only the namespace tuples after the ‘Track Namespace Prefix’”, which is nothing at all once the prefix names the whole namespace, and its SUBSCRIBE_NAMESPACE describes the prefix as “between 0 and 32 Track Namespace Fields”. Drafts 07 through 15 put the minimum at one field everywhere, drafts 08 through 15 spelling out that zero closes the session, so none of them has any use for this reader.

Because draft-16 is its only draft, the fields are held to both rules draft-16 Section 2.4.1 states about their contents: no field of length zero, and at most 4,096 bytes summed across the fields. A namespace being read for an earlier draft belongs in decode, which states neither.

Source

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

Decode a namespace tuple, holding it to rules.

The reader for drafts 07 through 16, which write both the field count and every field length as a QUIC variable-length integer (RFC 9000 Section 16). Drafts 17 and later changed that encoding and read namespaces through decode_moqt instead.

The upper bound on the field count is not part of rules: every draft from 07 on puts it at 32 and none has moved it, so it is applied here unconditionally. The byte cap is applied to the running sum as the field lengths are read, so a namespace that overruns is refused before its remaining fields are allocated.

Source

pub fn encode_moqt<P: MoqtProfile>(&self, buf: &mut impl BufMut)

Encode the namespace tuple using the MoQT varint (drafts 17 and later).

Source

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

Decode a namespace tuple using the MoQT varint (drafts 17 and later).

A field count of zero is accepted. Drafts 17, 18 and 19 all define a Track Namespace as “an ordered set of between 0 and 32 Track Namespace Fields”, and state only one field-count violation: “If an endpoint receives a Track Namespace consisting of greater than 32 Track Namespace Fields, it MUST close the session with a PROTOCOL_VIOLATION.” Draft-16 Section 2.4.1 says “between 1 and 32” instead, which is why the pre-17 decode still refuses an empty tuple and this does not.

Refusing the empty tuple here would also have made the codec emit frames it will not read: encode_moqt writes a zero field count without complaint, so the two directions disagreed about a shape the draft permits.

This leaves decode_moqt and decode_allow_empty_moqt accepting the same field counts on drafts 17 and later. Both are kept because the distinction is still real one draft earlier, where decode and decode_allow_empty part company over it, and because a call site naming the one it means says which rule it is relying on.

Source

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

Decode a MoQT namespace tuple that may have zero elements (suffix types).

Source

pub fn field_bytes_len(&self) -> usize

The sum of this namespace’s Track Namespace Field Length fields.

Section 2.4.1 defines both caps in terms of this sum: a Track Namespace is capped at 4,096 bytes on its own, and a Full Track Name is capped at this plus the Track Name Length.

Source

pub fn validate_moqt(&self) -> Result<(), CodecError>

Hold this namespace to the rules drafts 17 and later state in Section 2.4.1, before it goes on the wire.

The encode-side mirror of decode_allow_empty_moqt: at most 32 fields, no empty field, and at most 4,096 bytes of field content. Without it the codec would emit namespaces its own decoder refuses, and hand a conforming peer a reason to close the session.

Source

pub fn validate(&self, rules: TrackNamespaceRules) -> Result<(), CodecError>

Hold this namespace to rules before it goes on the wire.

The encode-side mirror of decode_rules, taking the same description of what a draft permits so that the two directions cannot drift apart. A codec that writes what it will not read hands a conforming peer a reason to close the session, and finds out only when the peer does.

The upper bound on the field count is not part of rules here either: every draft from 07 on puts it at 32.

Trait Implementations§

Source§

impl Clone for TrackNamespace

Source§

fn clone(&self) -> TrackNamespace

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 TrackNamespace

Source§

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

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

impl Eq for TrackNamespace

Source§

impl PartialEq for TrackNamespace

Source§

fn eq(&self, other: &TrackNamespace) -> 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 TrackNamespace

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.