Skip to main content

DraftVersion

Enum DraftVersion 

Source
pub enum DraftVersion {
Show 15 variants Draft07, Draft08, Draft09, Draft10, Draft11, Draft12, Draft13, Draft14, Draft15, Draft16, Draft17, Draft18, Draft19, Draft20, Draft21,
}
Expand description

MoQT draft version for runtime codec selection.

Variants§

§

Draft07

draft-ietf-moq-transport-07.

§

Draft08

draft-ietf-moq-transport-08.

§

Draft09

draft-ietf-moq-transport-09.

§

Draft10

draft-ietf-moq-transport-10.

§

Draft11

draft-ietf-moq-transport-11.

§

Draft12

draft-ietf-moq-transport-12.

§

Draft13

draft-ietf-moq-transport-13.

§

Draft14

draft-ietf-moq-transport-14.

§

Draft15

draft-ietf-moq-transport-15.

§

Draft16

draft-ietf-moq-transport-16.

§

Draft17

draft-ietf-moq-transport-17.

§

Draft18

draft-ietf-moq-transport-18.

§

Draft19

draft-ietf-moq-transport-19.

§

Draft20

draft-ietf-moq-transport-20.

§

Draft21

draft-ietf-moq-transport-21.

Implementations§

Source§

impl DraftVersion

Source

pub const ALL: [DraftVersion; 15]

Every draft of the series, oldest first.

The variants are not feature-gated, so this is the whole series whatever the build compiles. It answers which drafts exist, which is a property of the specification; which drafts this binary can decode is a different question with a different answer per feature set, and moqtap-proxy’s draft_is_compiled is where that one lives.

Sweeps should read this rather than write their own list. A written-out draft list is the most expensive silent defect this workspace has: it compiles, it passes, and it tests one draft fewer than it claims to. shape/matcher.rs shipped a [DraftVersion; 13] under a doc comment claiming the whole series, and every unit test that swept it stopped covering the newest draft without failing. A sweep over ALL cannot do that, and a sweep that deliberately covers less than the series – one draft per era, or the drafts that have a joining fetch - still writes its own list and still says why.

An array rather than a slice, so for d in DraftVersion::ALL yields drafts and not references and a caller can name the type. The length beside it is checked by the compiler against the contents, so it cannot silently disagree with them - and the contents are the half that goes wrong. scripts/check-draft-parity.py holds those against the enum, the per-draft source directories, the cargo features and the CI rows on every run, and the tests below hold them against from_number.

Source

pub const fn newest() -> DraftVersion

The newest draft of the series.

ALL is ordered, so this is its last element. Written as a method rather than left to the caller because ALL.last().unwrap() in a hundred places is a hundred unwraps, and because a caller that wants “the newest” almost always wants it infallibly.

Source

pub fn version_varint(&self) -> VarInt

The MoQT version number this draft would announce in CLIENT_SETUP.

Format: 0xff000000 + draft_number.

From draft-15 on there is no such value on the wire at all. Draft-15 deleted the version field from CLIENT_SETUP and moved version selection into the ALPN (moqt-<N>, see Self::quic_alpn), so the number this returns for drafts 15 through 21 — 0xff00000f through 0xff000015 — is a continuation of the mapping and not something a peer can observe or send. Nothing in this crate encodes it for those drafts. It is kept so that a caller with a draft in hand can name the version the series would have used, and so the mapping does not acquire a hole.

A tool that tries to detect the negotiated draft by looking for 0xff0000NN in a capture will find nothing from draft-15 on; the ALPN is the only signal.

Source

pub fn quic_alpn(&self) -> &'static [u8]

The ALPN protocol identifier for raw QUIC connections.

Drafts 07–14 all use moq-00 and negotiate the draft version in CLIENT_SETUP / SERVER_SETUP. Draft-15+ encode the draft number in the ALPN itself (moqt-<N>), so version selection happens during the TLS handshake rather than after it.

Source

pub fn from_alpn(alpn: &[u8]) -> Option<DraftVersion>

Resolve an ALPN identifier to a specific draft version.

Returns Some for ALPNs that unambiguously identify a draft (moqt-15 through moqt-21). Returns None for moq-00 — which covers drafts 07–14 and requires inspecting CLIENT_SETUP’s supported-versions list — and for any unrecognized ALPN.

Source

pub fn from_number(n: u8) -> Option<DraftVersion>

Resolve a draft number (e.g. 7..=21) to a DraftVersion.

Returns None for numbers outside the supported range.

Source

pub fn uses_fixed_length_framing(&self) -> bool

Whether this draft uses a 16-bit big-endian message length in control message framing (true) or a QUIC varint (false).

Draft-11 changed the framing from Length(i) to Length(16).

Source

pub fn varint_encoding(&self) -> VarIntEncoding

Which variable-length integer encoding this draft’s wire format uses.

Matched draft by draft rather than derived from the number. The series has already changed encoding once mid-stream and revised it again a draft later, so there is no rule to extrapolate from: adding a variant to DraftVersion must fail to compile here until someone reads that draft and says which encoding it uses.

Source

pub fn uses_moqt_varint(&self) -> bool

Whether this draft uses one of MoQT’s own variable-length integers rather than RFC 9000’s.

Source

pub fn varint_len(&self, first_byte: u8) -> usize

The total encoded length of a variable-length integer, from its first byte, under this draft’s encoding.

Available without a buffer, because a reader needs it to know how many bytes to wait for before it can decode at all. On draft-17 a first byte of 11111100 reports 7 even though the draft forbids that length: the reader waits for the whole field, then Self::decode_varint rejects it.

Source

pub fn decode_varint(&self, buf: &mut impl Buf) -> Result<VarInt, VarIntError>

Decode a variable-length integer under this draft’s encoding.

Source

pub fn encode_varint(&self, value: VarInt, buf: &mut impl BufMut)

Encode a variable-length integer under this draft’s encoding.

Source

pub fn number(&self) -> u8

The draft number (e.g. 7, 14, 21).

Trait Implementations§

Source§

impl Clone for DraftVersion

Source§

fn clone(&self) -> Self

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 Copy for DraftVersion

Source§

impl Debug for DraftVersion

Source§

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

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

impl Display for DraftVersion

Source§

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

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

impl Eq for DraftVersion

Source§

impl Hash for DraftVersion

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for DraftVersion

Source§

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

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.