Expand description
Draft-20 control message encoding and decoding.
Key differences from draft-19:
- FETCH (0x16) is a different message. The
Fetch Typefield is gone, and with it the Standalone Fetch and Joining Fetch structures and the Fetch Type registry. Track Namespace and Track Name are inline fields of FETCH, and the range travels in theLOCATION_FILTERparameter (Section 10.13, Figure 16). - PUBLISH_STATE_NOTIFY (0x22) is new and carries no Request ID (Section 10.10, Figure 13).
LOCATION_FILTER(0x21) has a new value shape. The Filter Type enum is gone; the shape comes from how manyvi64fields the value holds (Section 5.1.2).FILL_PARAMETERS(0x23) is new: a length-prefixed parameter carrying a nested parameter block in its own scope (Section 10.2.15).INCLUDE_PROPERTIES(0x35) is new: a uint8 restricted to 0 and 1 (Section 10.2.21).- Parameter applicability moved off
PUBLISH_OK. Six definitions dropped it and several gainedPUBLISH; onlyEXPIRESstill names it. PUBLISH_DONEβsSUBSCRIPTION_ENDEDstatus (0x3) andREQUEST_ERRORβsINVALID_JOINING_REQUEST_ID(0x32) are unassigned here.- Section numbering shifted from Section 10.10 on; every reference in this module is draft-20βs own.
Re-exportsΒ§
use crate::auth_token::AuthorizationToken;πuse crate::auth_token::AUTH_TOKEN_PARAMETER;πuse crate::error::MAX_FULL_TRACK_NAME_LENGTH;πpub use crate::error::CodecError;pub use crate::error::MAX_GOAWAY_URI_LENGTH;pub use crate::error::MAX_MESSAGE_LENGTH;pub use crate::error::MAX_NAMESPACE_TUPLE_SIZE;pub use crate::error::MAX_REASON_PHRASE_LENGTH;use crate::kvp::KeyValuePair;πuse crate::kvp::KvpError;πuse crate::kvp::KvpValue;πuse crate::kvp::MAX_KVP_VALUE_LEN;πuse crate::varint::Moqt18 as Wire;πuse crate::varint::VarInt;πuse bytes::Buf;πuse bytes::BufMut;πuse crate::types::*;π
ModulesΒ§
- publish_
done_ codes - Numeric values for the
PublishDonefields. - request_
error_ codes - REQUEST_ERROR error codes with dedicated meaning.
StructsΒ§
- Fetch
- FETCH (0x16), rebuilt in draft-20 (Section 10.13, Figure 16).
- FetchOk
- FETCH_OK (0x18).
end_of_trackis uint8. - GoAway
- GOAWAY (0x10). Draft-20βs GOAWAY has no Request ID field, so the control-stream and request-stream forms are identical on the wire. Draft-18 is the one draft that carries the field, and only when the message is sent on the control stream.
- Namespace
- Namespace
Done - Publish
- Publish
Done - PUBLISH_DONE (0x0B). The wire layout is unchanged from draft-19; what
draft-20 changed is the
Stream Countsentinel, what the count includes, and the removal of status code 0x3. - Publish
Namespace - Publish
Skipped - PUBLISH_SKIPPED (0x0F). Drafts 17 and 18 name this codepoint PUBLISH_BLOCKED; the wire layout β track namespace suffix then track name β is the same on all four drafts that carry the message.
- Publish
State Notify - PUBLISH_STATE_NOTIFY (0x22), new in draft-20 (Section 10.10, Figure 13).
- Redirect
- Optional Redirect structure carried in REQUEST_ERROR with code 0x34.
- Request
Error - REQUEST_ERROR (0x05). Adds an optional Redirect structure when
error_codeis REDIRECT (0x34). - Request
Ok - REQUEST_OK (0x07). Used as a generic OK response and as the alias for PUBLISH_OK / REQUEST_UPDATE_OK / TRACK_STATUS_OK / SUBSCRIBE_NAMESPACE_OK / PUBLISH_NAMESPACE_OK.
- Request
Update - Setup
- Unified SETUP (0x2F00).
- Subscribe
- Subscribe
Namespace - SUBSCRIBE_NAMESPACE (0x50). Subscribes to NAMESPACE / NAMESPACE_DONE
advertisements for namespaces matching
namespace_prefix. Only drafts 16 and 17 carry asubscribe_optionsvarint here; on draft-20 a namespace subscription only produces NAMESPACE / NAMESPACE_DONE. - Subscribe
Ok - SUBSCRIBE_OK (0x04).
- Subscribe
Tracks - SUBSCRIBE_TRACKS (0x51, new in draft-18). Subscribes to PUBLISH messages
for tracks whose namespace matches
namespace_prefix. Carries the FORWARD parameter (Section 10.2.18), which on drafts 15 through 17 may appear on SUBSCRIBE_NAMESPACE instead. - Track
Status
EnumsΒ§
- Control
Message - Message
Type - Param
Encoding π - How a parameter value is encoded on the wire.
ConstantsΒ§
- AUTHORIZATION_
TOKEN π - AUTHORIZATION TOKEN, Parameter Type 0x03.
- FILL_
PARAMETERS - The FILL_PARAMETERS parameter type, draft-20 Section 10.2.15. New in draft-20.
- FILL_
PARAMETERS_ πALLOWED - The parameter types draft-20 Section 10.2.15, Table 6 permits inside a
FILL_PARAMETERSvalue, in ascending order. - IMMUTABLE_
PROPERTIES π - Immutable Properties, Property Type 0xB.
- KNOWN_
SETUP_ πOPTIONS - The Setup Option types this draft defines.
- LOCATION_
FILTER - The LOCATION_FILTER parameter type, draft-20 Section 10.2.9.
- LOCATION_
FILTER_ πMAX_ FIELDS - The most
vi64fields aLOCATION_FILTERvalue can hold:StartGroup,StartObject,EndGroupDelta,EndObject(draft-20 Section 5.1.2). - REPEATABLE_
SETUP_ πOPTION - The one Setup Option whose definition allows more than one instance.
FunctionsΒ§
- add_
delta π - Add a delta to the previous delta-encoded key.
- check_
authorization_ πtokens - Hold every AUTHORIZATION TOKEN parameter to the Token structure it names.
- check_
discriminators π - Refuse a message whose discriminator disagrees with the fields beside it.
- check_
full_ πtrack_ name - Hold a namespace-plus-name pair to the Full Track Name cap.
- check_
location_ πfilter_ fields - Hold a decoded
LOCATION_FILTERto the one arithmetic rule draft-20 states about it. - check_
location_ πfilters - Hold every LOCATION_FILTER and FILL_PARAMETERS parameter to the structure its own type names.
- check_
parameter_ πscope - Refuse a message carrying a Message Parameter its own definition does not place there.
- check_
track_ πproperty_ values - Refuse a Track Property whose value falls outside the range its type allows, wherever in the list it is carried.
- decode_
fill_ parameters - Decode the nested parameter block a
FILL_PARAMETERSvalue carries. - decode_
kvp_ πdelta - Decode delta-encoded KVPs with even/odd convention (for setup options and track properties). Read until buffer is exhausted.
- decode_
location_ filter - Decode the
vi64fields of a draft-20LOCATION_FILTERvalue. - decode_
parameter_ πvalue - Read one parameterβs value in the shape its type names.
- decode_
parameters π - Decode a count-prefixed list of parameters with delta-encoded types.
- decode_
setup_ πoptions - Decode the Setup Options of a SETUP message.
- decode_
track_ πproperties - Decode the Track Properties that fill the tail of a control message.
- encode_
kvp_ πdelta - Encode delta-encoded KVPs with even/odd convention.
- encode_
parameters π - Encode a count-prefixed list of parameters with delta-encoded types.
- encode_
setup_ πoptions - Encode the Setup Options of a SETUP message.
- encode_
track_ πproperties - Encode a control messageβs Track Properties.
- is_
location_ πvalue - Whether
bytesis exactly the wire form of a Location β two consecutive varints and nothing after them. - is_
track_ πnamespace_ value - Whether
bytesis exactly the wire form of a Track Namespace, with nothing after it. The same reasoning asis_location_value: the value goes out verbatim, so it has to be something this draft can read back. - param_
encoding π - parameter_
in_ scope - Whether draft-20 lets Message Parameter
keyappear inmessage. - parameter_
may_ πrepeat - Whether draft-20 lets a message carry parameter type
keymore than once. - track_
property_ πvalue_ in_ range - Whether
valueis inside the range draft-20 allows for a Track Property type that restricts one. - uint8_
value_ πin_ range - Whether
valueis inside the range draft-20 allows for a uint8-valued parameter.