Skip to main content

Source

Struct Source 

Source
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

Source

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.

Source

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.

Source

pub fn broadcast(&self) -> Consumer

The catalog broadcast, the one at this source’s path.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Source

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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