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: TokenAliasTypeWhich 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
impl AuthorizationToken
Sourcepub fn decode(key: u64, bytes: &[u8]) -> Result<Self, CodecError>
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.
Sourcepub fn decode_moqt<P: MoqtProfile>(
key: u64,
bytes: &[u8],
) -> Result<Self, CodecError>
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.
Sourcepub fn encode(&self, buf: &mut impl BufMut) -> Result<(), CodecError>
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.
Sourcepub fn encode_moqt<P: MoqtProfile>(&self, buf: &mut impl BufMut)
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
impl Clone for AuthorizationToken
Source§fn clone(&self) -> AuthorizationToken
fn clone(&self) -> AuthorizationToken
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more