Skip to main content

Module message

Module message 

Source
Expand description

Draft-23 control message encoding and decoding.

  • The Message Length is a vi64 (Section 9, Figure 6), bounded by the receiver’s MAX_CONTROL_MESSAGE_SIZE (Section 9.1.8), 65535 unless the receiver advertised more. ControlMessage::decode and ControlMessage::encode use that default; ControlMessage::decode_with_limit and ControlMessage::encode_with_limit take the limit.
  • FETCH is answered by REQUEST_OK; type 0x18 is reserved (Section 9, Table 5).
  • REQUEST_ERROR ends in Error Details, Key-Value-Pairs (Section 9.4.1).
  • NAMESPACE carries a parameter block (Section 9.15, Figure 20).
  • FILL_PARAMETERS (0x23) is a parameter count followed by that many parameters, with no length (Section 9.19.15).
  • PAUSED (0x11, Section 9.19.18) and SUBSCRIBE_TRACKS_ID (0x36, Section 9.19.21).

Every section, table and figure reference in this module is draft-23’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Β§

error_detail_types
The Error Detail types draft-23 Section 16.11, Table 19 assigns.
location_filter_types
The Location Filter Type values draft-23 Section 9.19.9 assigns, named as Table 6 names them.
publish_done_codes
Numeric values for the PublishDone fields.
request_error_codes
REQUEST_ERROR error codes with dedicated meaning.

StructsΒ§

Fetch
FETCH (0x16), Section 9.11, Figure 17.
GoAway
GOAWAY (0x10). There is no Request ID field, so the control-stream and request-stream forms are identical on the wire.
Namespace
NAMESPACE (0x08), Section 9.15, Figure 20: a Track Namespace Suffix, then a parameter block.
NamespaceDone
Publish
PublishDone
PUBLISH_DONE (0x0B).
PublishNamespace
PublishSkipped
PUBLISH_SKIPPED (0x0F): a track namespace suffix, then a track name.
PublishStateNotify
PUBLISH_STATE_NOTIFY (0x22), Section 9.10, Figure 16.
Redirect
The value of a REDIRECT Error Detail (Section 9.4.2.1).
RequestError
REQUEST_ERROR (0x05), Section 9.4.1, Figure 10.
RequestOk
REQUEST_OK (0x07), the response to PUBLISH, FETCH, REQUEST_UPDATE, TRACK_STATUS, SUBSCRIBE_NAMESPACE, SUBSCRIBE_TRACKS and PUBLISH_NAMESPACE (Section 9.3).
RequestUpdate
Setup
Unified SETUP (0x2F00).
Subscribe
SubscribeNamespace
SUBSCRIBE_NAMESPACE (0x50). Subscribes to NAMESPACE / NAMESPACE_DONE advertisements for namespaces matching namespace_prefix.
SubscribeOk
SUBSCRIBE_OK (0x04).
SubscribeTracks
SUBSCRIBE_TRACKS (0x51). Subscribes to PUBLISH messages for tracks whose namespace matches namespace_prefix.
TrackStatus

EnumsΒ§

ControlMessage
MessageType
The control message types draft-23 Section 9, Table 5 assigns.
ParamEncoding πŸ”’
How a parameter value is encoded on the wire.
RequestOkKind
The request a RequestOk answers, named by Section 1.5’s shorthand.

ConstantsΒ§

AUTHORIZATION_TOKEN πŸ”’
AUTHORIZATION TOKEN, Parameter Type 0x03.
DEFAULT_MAX_CONTROL_MESSAGE_SIZE
The MAX_CONTROL_MESSAGE_SIZE an endpoint uses for its peer until it has the peer’s SETUP, and when the SETUP carries none.
FILL_PARAMETERS
The FILL_PARAMETERS parameter type, draft-23 Section 9.19.15.
FILL_PARAMETERS_ALLOWED πŸ”’
The parameter types draft-23 Section 9.19.15, Table 7 permits inside a FILL_PARAMETERS value, in ascending order. β€œAn endpoint that receives a parameter inside FILL_PARAMETERS that is not listed above MUST close the session with INVALID_PARAMETER.”
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-23 Section 9.19.9.
MAX_CONTROL_MESSAGE_SIZE_OPTION
The MAX_CONTROL_MESSAGE_SIZE Setup Option type, Section 9.1.8.
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_error_details πŸ”’
Hold a REQUEST_ERROR’s Error Details to its Error Code.
check_error_details_to_send πŸ”’
The sender’s half of check_error_details, plus Section 9.4.2: β€œSenders MUST NOT repeat the same Error Detail type in a message unless the type’s definition explicitly allows multiple instances.” Only UNSUPPORTED_PROPERTY allows them, and a type this draft does not define is the caller’s to repeat or not.
check_full_track_name πŸ”’
Hold a namespace-plus-name pair to the Full Track Name cap.
check_location_filter_fields πŸ”’
Hold a decoded LOCATION_FILTER to the one arithmetic rule draft-23 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 (Section 9.19.1).
check_setup_token_aliases πŸ”’
Refuse a SETUP token that names an Alias with DELETE or USE_ALIAS.
check_track_name πŸ”’
Refuse an empty Track Name.
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 parameters a FILL_PARAMETERS value 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 a draft-23 LOCATION_FILTER value into its Location Filter Type and the fields that type names.
decode_max_control_message_size
The value of a MAX_CONTROL_MESSAGE_SIZE option: the one vi64 its bytes hold.
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_property_list πŸ”’
Decode bytes as a run of Key-Value-Pairs, the shape of an Immutable Properties value (Section 10.7).
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_fill_parameters
Encode params as a FILL_PARAMETERS value, the inverse of decode_fill_parameters.
encode_kvp_delta πŸ”’
Encode delta-encoded KVPs with even/odd convention.
encode_max_control_message_size
The bytes of a MAX_CONTROL_MESSAGE_SIZE option carrying size.
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 bytes is exactly the wire form of a Location β€” two consecutive varints and nothing after them.
is_track_namespace_value πŸ”’
Whether bytes is exactly the wire form of a Track Namespace, with nothing after it. The same reasoning as is_location_value: the value goes out verbatim, so it has to be something this draft can read back.
location_filter_field_count
How many vi64 fields follow a Location Filter Type, or None for a type draft-23 does not assign.
max_control_message_size
The MAX_CONTROL_MESSAGE_SIZE a SETUP’s options advertise, or the default.
param_encoding πŸ”’
parameter_in_scope
Whether draft-23 lets Message Parameter key appear in message.
parameter_may_repeat πŸ”’
Whether draft-23 lets a message carry parameter type key more than once.
read_fill_parameters πŸ”’
Read one FILL_PARAMETERS value off buf: its Number of Parameters and that many parameters.
read_location_filter πŸ”’
Read one LOCATION_FILTER value off buf: the Location Filter Type, then exactly the fields that type names.
track_property_value_in_range πŸ”’
Whether value is inside the range draft-23 allows for a Track Property type that restricts one.
uint8_value_in_range πŸ”’
Whether value is inside the range draft-23 allows for a uint8-valued parameter.
write_fill_parameters πŸ”’
Write a FILL_PARAMETERS value: the count and the inner parameters, with no length ahead of them.
write_location_filter πŸ”’
Write a LOCATION_FILTER value in its minimal encoding: the type, then the fields, each the shortest vi64 that holds it.