pub struct Source { /* private fields */ }Expand description
The subscription side of an export: an origin and the catalog broadcast that drives it.
Every rendition (including ones whose catalog broadcast field references a sibling
broadcast) resolves against origin, so a source can always follow a cross-broadcast
reference. Build one with Source::new.
A source serves its own path from the broadcast it was built from, and keeps the first
broadcast it resolves for each sibling, waiting for the sibling’s first announcement if
nothing serves it yet. Every later request for a path is served from that handle
(broadcast, catalog, resolve,
bind, subscribe_track, and an export’s track
requests). A route replaced after that is never resolved, one identity or not, so two publishers
never splice into one export; a request on a held broadcast that has ended fails instead of
waiting for the next one. Clones share the held broadcasts.
A reader that follows a sibling’s announcements instead, restarting on each new identity,
uses follow, which holds nothing.
Implementations§
Source§impl Source
impl Source
Sourcepub fn new(origin: Consumer, broadcast: Consumer) -> Self
pub fn new(origin: Consumer, broadcast: Consumer) -> Self
A source driven by the catalog of broadcast, resolving its references through origin.
broadcast is the catalog broadcast as resolved through origin: a rendition’s relative
broadcast reference resolves against its path, and the
referenced broadcast is fetched via
origin.request, so it must be
reachable through origin (by exact path, or served by a dynamic handler). A standalone
broadcast has an empty path, so it is its own root and any .. reference escapes.
Sourcepub fn stats(&self) -> BTreeMap<String, Rendition>
pub fn stats(&self) -> BTreeMap<String, Rendition>
What each rendition exported through this source (and its clones) has received, keyed by rendition ID in the catalog that listed it, including renditions referenced from another broadcast.
Counters are cumulative for the life of the source, across resubscriptions and a
Follower switching identities, so a rendition no export
reads any more keeps its final counts, until 1,024 renditions are held: then those no export
reads make way for new ones. Fold this into an
echo::Snapshot on the feedback interval.
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 fn resolve_reference(&self, rel: Option<&Relative>) -> Option<Path>
pub fn resolve_reference(&self, rel: Option<&Relative>) -> Option<Path>
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, waiting for its first announcement if nothing serves it yet.
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 path nothing announces yet resolves once something does, and a remote or dynamic
handler may answer later. A client session that only discovers what is watched is asked
about the path while the binding waits. Once answered, the binding never resolves the path again, even
after its publisher is replaced or goes; follow does.
A path this source already resolved binds to that broadcast; otherwise the origin is
asked, deduplicating repeat requests for one path so the catalog and every rendition share
one upstream subscription, and its answer is pinned. 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 is resolved as in
resolve, waiting for its first announcement. 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
use it to honor cross-broadcast renditions without reimplementing the path math.
Sourcepub fn follow(&self, rel: Option<&Relative>) -> Result<Identities>
pub fn follow(&self, rel: Option<&Relative>) -> Result<Identities>
Follow the broadcast a rendition’s reference names across its announcements.
Holds nothing: each identity serving a sibling is handed out as it comes online or takes over, and its end is reported, so a reader restarts the rendition on each one. A reference to the catalog broadcast itself hands out only the broadcast this source was built from and never reports its end, since a reader follows its catalog’s own end and restarts by building a new source.
Rejects an escaping reference exactly as resolve does.