Skip to main content

AuthorizationToken

Struct AuthorizationToken 

Source
pub struct AuthorizationToken {
    pub alias_type: TokenAliasType,
    pub alias: Option<u64>,
    pub token_type: Option<u64>,
    pub value: Vec<u8>,
}
Expand description

The Token structure an AUTHORIZATION TOKEN parameter carries as its value.

Drafts 11 through 19 serialize it as

Token {
  Alias Type (i),
  [Token Alias (i),]
  [Token Type (i),]
  [Token Value (..)]
}

with the Alias Type deciding which of the bracketed fields are present. The Token Value has no length of its own and runs to the end of the parameter value, which is what bounds it — draft-19 Section 1.4.3 says so outright: “Key-Value-Pairs are always parsed with a known byte length, which bounds the sequence.”

The structure has not moved across the nine drafts that define it. Only the integer encoding has: drafts 11 through 16 write the three integers as QUIC variable-length integers and drafts 17 and later as MoQT ones, which is the only difference between decode and decode_moqt.

The contents of the Token Value are deliberately opaque here. “The contents and serialization of this payload are defined by the Token Type”, and that registry is not this codec’s to interpret — Token Type 0 is reserved for a meaning “negotiated out-of-band between client and receiver”, so no reader can hold the value to a shape without knowing what the two peers agreed.

Fields§

§alias_type: TokenAliasType

Which of the fields below are present, and what the receiver does with them.

§alias: Option<u64>

The Session-specific Alias, present on every form but USE_VALUE.

§token_type: Option<u64>

The Token Type, present on REGISTER and USE_VALUE.

§value: Vec<u8>

The Token Value, present on REGISTER and USE_VALUE and running to the end of the parameter value. Empty on DELETE and USE_ALIAS.

Implementations§

Source§

impl AuthorizationToken

Source

pub fn decode(key: u64, bytes: &[u8]) -> Result<Self, CodecError>

Decode a Token from a parameter value written with QUIC variable-length integers, as drafts 11 through 16 write them.

key is the parameter type the value arrived under. It is carried into the error rather than used for the parse: the caller knows which namespace it read, and a report naming 0x03 when the frame said 0x01 sends the reader to the wrong table.

Source

pub fn decode_moqt<P: MoqtProfile>( key: u64, bytes: &[u8], ) -> Result<Self, CodecError>

Decode a Token from a parameter value written with MoQT variable-length integers, as drafts 17 and later write them.

Source

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

Write this Token as a parameter value, using QUIC variable-length integers (drafts 11 through 16).

Fallible where encode_moqt is not, for the reason the two integer encodings differ: the QUIC one stops at 2^62 - 1, so an Alias or Token Type above that has no representation and would otherwise be written as an unrelated number with the length bits folded into it.

The fields written are the ones the Alias Type promises, not the ones that happen to be populated. A caller that sets a Token Alias on a USE_VALUE has described a structure no draft defines, and writing it would produce bytes this codec’s own reader refuses; the Alias Type is the field a receiver parses by, so it is the field that decides.

Source

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

Write this Token as a parameter value, using MoQT variable-length integers (drafts 17 and later).

Infallible: that encoding reaches the whole 64-bit range, so every value these fields can hold has a representation.

Trait Implementations§

Source§

impl Clone for AuthorizationToken

Source§

fn clone(&self) -> AuthorizationToken

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 AuthorizationToken

Source§

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

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

impl Eq for AuthorizationToken

Source§

impl PartialEq for AuthorizationToken

Source§

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

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, <T as TryFrom<U>>::Error>

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.