pub struct Source { /* private fields */ }Expand description
The subscription side of an export: an origin and the path of the broadcast whose catalog drives it.
The catalog broadcast and every rendition (including ones whose catalog
broadcast field references a sibling broadcast) resolve against origin,
so a source can always follow a cross-broadcast reference. Build one with
Source::new.
Implementations§
Source§impl Source
impl Source
Sourcepub fn new(origin: Consumer, path: impl AsPath) -> Self
pub fn new(origin: Consumer, path: impl AsPath) -> Self
A source rooted at origin, driven by the catalog of the broadcast at path.
path names the broadcast whose catalog is exported; a rendition’s relative
broadcast reference is resolved against it. Both the catalog broadcast and any
referenced broadcast are fetched via
origin.request_broadcast, so they
must be reachable through origin (by exact path, or served by a dynamic handler).
Sourcepub async fn broadcast(&self) -> Result<Consumer>
pub async fn broadcast(&self) -> Result<Consumer>
Resolve and subscribe to the catalog broadcast (the one at this source’s path).
Sourcepub async fn catalog<E: CatalogExt>(
&self,
format: CatalogFormat,
) -> Result<Consumer<E>>
pub async fn catalog<E: CatalogExt>( &self, format: CatalogFormat, ) -> Result<Consumer<E>>
Subscribe to this broadcast’s catalog.
The stream rejects a catalog carrying a broadcast reference that walks above the root
(see Error::EscapingBroadcast), so every snapshot a
consumer sees is one whose references all name a broadcast it may reach.
Sourcepub async fn returned(&self, ended: &Consumer) -> Result<Consumer>
pub async fn returned(&self, ended: &Consumer) -> Result<Consumer>
Wait for the broadcast to come back after ended, the one an export was reading, closes.
A broadcast that stays up never returns, so a clean catalog end that leaves it announced waits here until the caller’s own deadline. Bound the wait with a timeout.
Sourcepub fn resolve_reference(&self, rel: Option<&Relative<'_>>) -> Option<PathOwned>
pub fn resolve_reference(&self, rel: Option<&Relative<'_>>) -> Option<PathOwned>
Resolve a rendition’s optional broadcast reference to an origin path.
A missing or empty reference returns the catalog broadcast path. A valid reference
may return the empty root path, which still names a broadcast. None means the
reference walked above the root and names nothing.
Sourcepub async fn resolve(&self, rel: Option<&Relative<'_>>) -> Result<Consumer>
pub async fn resolve(&self, rel: Option<&Relative<'_>>) -> Result<Consumer>
Resolve an optional cross-broadcast reference to its broadcast.
rel is a rendition’s catalog broadcast field: None (or an empty reference)
resolves the catalog broadcast itself; anything else fetches the referenced
broadcast from the origin. Use it when you need the broadcast handle itself
(e.g. to FETCH individual groups) rather than a subscription.
A reference that escapes above the origin root is
Error::EscapingBroadcast: the rendition names
no broadcast, so there is nothing to resolve.
Sourcepub fn bind(&self, rel: Option<&Relative<'_>>) -> Result<Binding>
pub fn bind(&self, rel: Option<&Relative<'_>>) -> Result<Binding>
Start one broadcast request now and retain its result for repeated reads.
Unlike resolve, this issues the request without awaiting or polling.
A remote or dynamic handler may answer later. The binding never retries a failed request
or resolves the path again after a publisher is replaced.
This always looks up the path, including for a self-reference. Use Binding::new
when the intended broadcast is already in hand.
Rejects an escaping reference exactly as resolve does.
Sourcepub async fn subscribe_track(
&self,
rel: Option<&Relative<'_>>,
name: &str,
) -> Result<Subscriber>
pub async fn subscribe_track( &self, rel: Option<&Relative<'_>>, name: &str, ) -> Result<Subscriber>
Resolve an optional cross-broadcast reference and subscribe to track name,
awaiting SUBSCRIBE_OK.
rel is a rendition’s catalog broadcast field: None (or an empty reference)
subscribes on the catalog broadcast; anything else fetches the referenced broadcast
from the origin first. A reference that escapes above the origin root is
Error::EscapingBroadcast.
This is the async counterpart to the poll-driven container exporters: consumers
that wrap a raw moq_net::track::Subscriber themselves (e.g. the WebRTC egress)
use it to honor cross-broadcast renditions without reimplementing the path math.