pub struct Consumer { /* private fields */ }Expand description
A handle to a single track within a broadcast.
Obtained from broadcast::Consumer::track. Holding it sends nothing
to the publisher; it just names a track you can subscribe
to (a live, ongoing stream of groups) later. The same handle can be subscribed
to multiple times, and clones are cheap.
A track reached through a route-fed broadcast is spliced: it is backed by one or more per-session tracks joined at group boundaries, and this handle reads across them transparently.
Implementations§
Source§impl Consumer
impl Consumer
Sourcepub fn broadcast(&self) -> &Info
pub fn broadcast(&self) -> &Info
The broadcast this track belongs to, as reached through the handle it came from.
Its path is what a catalog’s relative broadcast
references resolve against.
Sourcepub fn subscribe(
&self,
subscription: impl Into<Option<Subscription>>,
) -> Pending<Subscribing> ⓘ
pub fn subscribe( &self, subscription: impl Into<Option<Subscription>>, ) -> Pending<Subscribing> ⓘ
Open a live subscription.
Registers the subscription on the track and returns a kio::Pending that resolves to the
Subscriber once the track info is available, or the track’s abort error (or
Error::Dropped) if it is already closed.
The read cursor starts at the group the subscription named (its floor), or 0.
Subscription::max_age is what asks for data: delivery skips everything above
the floor that the budget convicts, so the default budget of zero delivers only
the latest group and a larger one reaches back over what it can still use.
Sourcepub fn fetch_group(
&self,
sequence: u64,
options: impl Into<Option<Fetch>>,
) -> Pending<Fetching> ⓘ
pub fn fetch_group( &self, sequence: u64, options: impl Into<Option<Fetch>>, ) -> Pending<Fetching> ⓘ
Fetching a single past group, without holding a live subscription.
Returns a kio::Pending that resolves to the group::Consumer:
immediately if the group is cached, otherwise once a Dynamic serves
the request (a wire FETCH for a relay). options accepts None, a group::Fetch,
or group::Fetch::default().
The returned future resolves to Error::NotFound when the group can never be served
(past the final sequence, or no Dynamic on the track), the handler’s rejection
(a relay’s upstream miss is StreamError::NotFound),
or the track’s abort error if it’s already closed. Concurrent fetches for the same sequence coalesce onto one
handler request.
Sourcepub fn query(&self) -> Pending<Querying> ⓘ
pub fn query(&self) -> Pending<Querying> ⓘ
Resolve the track’s Info without subscribing.
A Consumer is a lazy handle, so the info may not be known yet: this waits
for the producer to Request::accept the track (a wire TRACK_INFO round-trip
for a relay), and errors with the track’s abort error if it closes first.
Subscriber::info is the already-resolved counterpart.