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
impl TrackNamespace
Sourcepub fn decode(buf: &mut impl Buf) -> Result<Self, CodecError>
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.
Sourcepub fn decode_allow_empty(buf: &mut impl Buf) -> Result<Self, CodecError>
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.
Sourcepub fn decode_rules(
buf: &mut impl Buf,
rules: TrackNamespaceRules,
) -> Result<Self, CodecError>
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.
Sourcepub fn encode_moqt<P: MoqtProfile>(&self, buf: &mut impl BufMut)
pub fn encode_moqt<P: MoqtProfile>(&self, buf: &mut impl BufMut)
Encode the namespace tuple using the MoQT varint (drafts 17 and later).
Sourcepub fn decode_moqt<P: MoqtProfile>(
buf: &mut impl Buf,
) -> Result<Self, CodecError>
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.
Sourcepub fn decode_allow_empty_moqt<P: MoqtProfile>(
buf: &mut impl Buf,
) -> Result<Self, CodecError>
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).
Sourcepub fn field_bytes_len(&self) -> usize
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.
Sourcepub fn validate_moqt(&self) -> Result<(), CodecError>
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.
Sourcepub fn validate(&self, rules: TrackNamespaceRules) -> Result<(), CodecError>
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
impl Clone for TrackNamespace
Source§fn clone(&self) -> TrackNamespace
fn clone(&self) -> TrackNamespace
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more