Skip to main content

AnyConnection

Enum AnyConnection 

Source
pub enum AnyConnection {
Show 14 variants Draft07(Connection), Draft08(Connection), Draft09(Connection), Draft10(Connection), Draft11(Connection), Draft12(Connection), Draft13(Connection), Draft14(Connection), Draft15(Connection), Draft16(Connection), Draft17(Connection), Draft18(Connection), Draft19(Connection), Draft20(Connection),
}
Expand description

A MoQT client connection of any enabled draft version.

Wraps the draft-specific Connection type. Methods common to all drafts are forwarded; for draft-specific protocol calls, match on the variant.

Variants§

§

Draft07(Connection)

A draft-draft07 connection.

§

Draft08(Connection)

A draft-draft08 connection.

§

Draft09(Connection)

A draft-draft09 connection.

§

Draft10(Connection)

A draft-draft10 connection.

§

Draft11(Connection)

A draft-draft11 connection.

§

Draft12(Connection)

A draft-draft12 connection.

§

Draft13(Connection)

A draft-draft13 connection.

§

Draft14(Connection)

A draft-draft14 connection.

§

Draft15(Connection)

A draft-draft15 connection.

§

Draft16(Connection)

A draft-draft16 connection.

§

Draft17(Connection)

A draft-draft17 connection.

§

Draft18(Connection)

A draft-draft18 connection.

§

Draft19(Connection)

A draft-draft19 connection.

§

Draft20(Connection)

A draft-draft20 connection.

Implementations§

Source§

impl AnyConnection

Source

pub fn draft(&self) -> DraftVersion

Returns the draft version this connection is using.

Source

pub fn set_observer(&mut self, observer: Arc<dyn AnyConnectionObserver>)

Attach an observer. The observer is adapted into the draft-specific observer trait and installed on the inner connection; events are forwarded as AnyClientEvent.

Replaces any previously attached observer.

Source

pub fn clear_observer(&mut self)

Remove any attached observer.

Source

pub fn close(&self, code: u32, reason: &[u8])

Close the connection with the given application error code and reason.

Source§

impl AnyConnection

Source

pub async fn connect( addr: &str, config: AnyClientConfig, ) -> Result<Self, AnyConnectionError>

Connect to a MoQT server using the requested draft. Builds the draft-specific ClientConfig from the provided AnyClientConfig and dispatches to the appropriate Connection::connect.

Source

pub async fn recv_and_dispatch(&mut self) -> Result<(), AnyConnectionError>

Read and dispatch one control message on the active draft. Draft-specific control-message return values are discarded because event delivery goes through the attached observer; callers only care about success/failure.

Source

pub async fn unsubscribe( &mut self, request_id: VarInt, ) -> Result<(), AnyConnectionError>

Send an UNSUBSCRIBE for the given request ID. Drafts 07 through 16.

§Drafts 17 through 20 have no such message

Draft-17 deleted UNSUBSCRIBE, and drafts 18, 19 and 20 keep it deleted: a subscriber ends a subscription by resetting its request stream, which is AnyRequest::cancel, or waits for PUBLISH_DONE. So the error those four return is not a gap to be filled later — there is nothing to wire — and a caller reaching for it on one of them wants cancel on the handle subscribe returned.

Source

pub async fn subscribe( &mut self, namespace: TrackNamespace, track_name: Vec<u8>, subscriber_priority: u8, group_order: GroupOrder, filter_type: FilterType, ) -> Result<AnyRequest, AnyConnectionError>

Send a SUBSCRIBE with the given filter, priority, and group order. Supported on drafts 12 through 20. Drafts 15 onward carry priority/order/filter as parameters rather than fields; this helper passes an empty parameter list, so on those drafts all three take the protocol default and the three arguments here are ignored.

There is no range to get wrong: a subscription with no filter is one that starts where the draft says it starts, and nothing is converted. A draft-20 caller that wants a Location filter, a fill, or anything else from Section 10.2 reaches draft20::connection::Connection::subscribe through the variant with the parameters it wants.

The returned AnyRequest must be held while the request is live: on drafts 17-20 it owns the bidirectional stream the request went out on and dropping it cancels the subscription. See AnyRequest for how the two kinds of handle differ.

Source

pub async fn fetch( &mut self, namespace: TrackNamespace, track_name: Vec<u8>, range: FetchRange, ) -> Result<AnyRequest, AnyConnectionError>

Send a standalone FETCH for range. Wired on drafts 14 through 20; every earlier draft returns the error at the end of the match.

§What the range means here

FetchEnd::Object is the last Object the fetch covers, and the range holds it. FetchEnd::EntireGroup covers the whole end Group. end_group is absolute. That is the whole contract, and it is stated in FetchEnd as well because it is the one thing about this call a caller can get wrong without being told.

The drafts do not agree, which is why the argument is a FetchRange rather than four numbers. Drafts 14 through 19 carry Start Location and End Location inline in FETCH, and all six word the end alike — draft-19 Section 10.12.1: “The end Location, plus 1. A Location.Object value of 0 means the entire group is requested.” The section number moves between drafts; the sentence does not. Draft-20 Section 10.13 deleted both fields and moved the range into the LOCATION_FILTER parameter, whose ranges Section 5.1.2 calls inclusive — the + 1 and the 0-means-whole- group convention are both gone, and neither deletion is in the draft’s own change log. A single end_object: u64 at this boundary would have meant one of those two things and looked like the other.

The conversion is FetchRange::inline_end_object for the first group and FetchRange::location_filter for draft-20. The + 1 exists in exactly one place, the first of those, so it cannot reach draft-20 by being ported.

§What this does not carry

An empty parameter list, on every draft. Draft-14’s subscriber priority and group order are fields of its FETCH and of no later draft’s, so they are sent as they always were. Reach a draft’s own Connection::fetch through the variant for anything past a plain range.

§Errors

A range the negotiated draft cannot express, before anything is written: FetchEnd::Object(u64::MAX) on drafts 14 through 19, and an end_group below start_group on draft-20. See the two conversions for why each is inexpressible rather than merely unusual.

The returned AnyRequest must be held while the request is live: on drafts 17-20 it owns the bidirectional stream the request went out on and dropping it cancels the fetch.

Source

pub async fn track_status( &mut self, namespace: TrackNamespace, track_name: Vec<u8>, ) -> Result<AnyRequest, AnyConnectionError>

Send a TRACK_STATUS query for the given track. Supported on drafts 14 through 20. From draft-15 on, passes an empty parameter list.

The returned AnyRequest must be held until the answer arrives: on drafts 17-20 it owns the bidirectional stream the query went out on and dropping it cancels the query.

Source

pub async fn subscribe_namespace( &mut self, namespace_prefix: TrackNamespace, ) -> Result<AnyRequest, AnyConnectionError>

Send a SUBSCRIBE_NAMESPACE (or SUBSCRIBE_ANNOUNCES on drafts 11–12). Supported on drafts 11 through 20. Drafts 16 and 17 pass default subscribe options; every draft from 12 on passes an empty parameter list.

From draft-18 this is the renumbered SUBSCRIBE_NAMESPACE (0x50), which asks for NAMESPACE and NAMESPACE_DONE only. SUBSCRIBE_TRACKS, the other half of the draft-18 split, has no entry point here — reach a draft’s own Connection::subscribe_tracks through the variant.

The returned AnyRequest must be held while the request is live: on drafts 17-20 it owns the bidirectional stream the request went out on and dropping it cancels the namespace subscription.

Source

pub async fn subscribe_update( &mut self, subscription_request_id: VarInt, start_location: Location, end_group: VarInt, subscriber_priority: u8, forward: Forward, ) -> Result<(), AnyConnectionError>

Send a SUBSCRIBE_UPDATE for an active subscription. Draft-14 only.

§Why no later draft is wired, and why that is not this call’s to fix

Draft-15 renamed the message REQUEST_UPDATE and rebuilt it, and from draft-17 it travels on the request’s own bidirectional stream rather than on a control stream — so an update needs the AnyRequest the original request returned, which this signature does not take and cannot be given without becoming a different call. Draft-20 goes further and has no start_location / end_group pair at all: Section 10.9 carries the new range as a LOCATION_FILTER parameter, on the same inclusive terms FetchRange describes. Reach a draft’s own Connection::send_on_request_stream through the variant.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more