Skip to main content

Session

Struct Session 

Source
pub struct Session { /* private fields */ }
Expand description

A relay session: the requests of moqt::client::Session, through Deref, with its token kept fresh. It follows GOAWAY and replaces a lost connection for up to 60 s, sending its namespaces and subscriptions again; when it cannot, the session ends with SessionEnd::ConnectionLost.

Implementations§

Source§

impl Session

Source

pub async fn closed(&self) -> SessionEnd

Waits for the session to end; returns at once if it already has.

Source

pub async fn close(&self)

Closes the session with NO_ERROR; closed resolves with SessionEnd::Closed.

Methods from Deref<Target = Session>§

pub fn moqt_session(&self) -> &Arc<Session> ⓘ

The wrapped session, for what this type does not cover; its events are not for the caller.

pub fn origin(&self) -> &Origin

The tracks publish_track registered, which a handler may write into as well.

pub fn add_handler(&self, handler: Arc<dyn EventHandler>) -> HandlerId

Hands the session’s events to handler before the Origin, after the handlers added earlier.

pub fn remove_handler(&self, id: HandlerId)

pub async fn subscribe( &self, namespace: &[impl AsRef<str>], track: &str, options: SubscribeOptions, ) -> Result<Subscription, RequestError>

SUBSCRIBE (draft-14 §9.7).

pub async fn subscribe_current_group( &self, namespace: &[impl AsRef<str>], track: &str, options: GroupStartOptions, ) -> Result<Subscription, RequestError>

Subscribes and reads the group the largest object is in from its first object, through a Joining FETCH (draft-14 §9.16.2).

pub async fn subscribe_group_start( &self, namespace: &[impl AsRef<str>], track: &str, new_group_after: u64, options: GroupStartOptions, ) -> Result<Subscription, RequestError>

Subscribes and reads the track from the first object of a group (draft-18 §5.1.3.1), chosen once the SUBSCRIBE_OK arrives: the current group, through a Joining FETCH, or, when the track has dynamic groups and its largest object ID is new_group_after or more, a new group it asks the publisher to start (NEW_GROUP_REQUEST, §10.2.13).

pub async fn fetch( &self, namespace: &[impl AsRef<str>], track: &str, start: Location, end: Location, ) -> Result<Fetch, FetchError>

A Standalone FETCH (draft-14 §9.16.1). end’s object is the last object plus 1, and 0 means the whole group. Returns once the response stream has arrived.

pub async fn track_status( &self, namespace: &[impl AsRef<str>], track: &str, ) -> Result<Option<Location>, RequestError>

TRACK_STATUS (draft-14 §9.20): the track’s largest location, or None while it has none.

pub async fn watch_namespaces( &self, prefix: &[impl AsRef<str>], ) -> Result<NamespaceWatch, RequestError>

SUBSCRIBE_NAMESPACE (draft-14 §9.28) for the namespaces under prefix. Fails when the SUBSCRIBE_NAMESPACE is rejected, as one whose prefix overlaps another watch_namespaces, watch_tracks or follow_track of this session is (NAMESPACE_PREFIX_OVERLAP).

pub async fn watch_tracks( &self, prefix: &[impl AsRef<str>], ) -> Result<TrackWatch, RequestError>

SUBSCRIBE_NAMESPACE (draft-14 §9.28) for the namespaces under prefix and their tracks: the watch reports each namespace and hands over each PUBLISH under it, which nothing else on the session then sees. Fails when the SUBSCRIBE_NAMESPACE is rejected, as one whose prefix overlaps another watch_namespaces, watch_tracks or follow_track of this session is (NAMESPACE_PREFIX_OVERLAP).

pub async fn follow_track( &self, namespace: &[impl AsRef<str>], track: &str, ) -> Result<TrackFollower, RequestError>

Follows track in namespace as peers publish it one after another, through a SUBSCRIBE_NAMESPACE (draft-14 §9.28) for the namespace and its tracks; see TrackFollower. Fails when the SUBSCRIBE_NAMESPACE is rejected, as one whose namespace overlaps another watch_namespaces, watch_tracks or follow_track of this session is (NAMESPACE_PREFIX_OVERLAP): one session follows one track per namespace.

pub async fn announce( &self, namespace: &[impl AsRef<str>], ) -> Result<Announcement, RequestError>

PUBLISH_NAMESPACE (draft-14 §9.23).

pub async fn publish_track( &self, namespace: &[impl AsRef<str>], track: &str, options: PublishTrackOptions, ) -> Result<TrackWriter, Error>

Registers a track to publish, whose group ids start at the wall-clock time in µs, so a later run of the same publisher does not reuse a location the relay still caches. A track registered again keeps its objects, so once it has one, registering it with the other datagram fails with PublishTrackError::OtherDelivery and changes nothing. Also fails when the PUBLISH fails.

pub fn transferred_bytes(&self) -> TransferredBytes

pub async fn closed(&self) -> TransportClose

Resolves once the session’s last connection has closed.

pub async fn close(&self)

Stops answering the peer, ends every namespace watch, done and next_subscriber, and closes the session with NO_ERROR, as moqt::Session::close does.

Trait Implementations§

Source§

impl Deref for Session

Source§

type Target = Session

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Session

Dereferences the value.

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.

§

impl<T> MaybeSend for T
where T: Send + ?Sized,

§

impl<T> MaybeSend for T
where T: Send + ?Sized,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSync for T
where T: Sync + ?Sized,

§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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