pub struct Consumer { /* private fields */ }Expand description
A lazy handle to a single track within a broadcast.
Obtained from broadcast::Consumer::track. Holding it sends nothing and is not
Demand: the track is requested, and counts as demanded, only while an
info, subscribe (a live, ongoing stream of
groups), or fetch_group (one group) made from it is held. The
same handle can be used any number of times, and clones are cheap.
Implementations§
Source§impl Consumer
impl Consumer
Sourcepub fn unmetered(self) -> Self
pub fn unmetered(self) -> Self
This handle with its stats scope cleared, so the subscriptions, fetches, and groups derived from it count toward no stats session: for reads a consumer makes for itself rather than on behalf of whoever its origin is metered for.
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.
Reads only the groups the subscription’s ranges cover. A group reached only through
live joins is skipped once the widest of their max convicts it, so the default
Start::LATEST delivers only the latest group; a history range delivers every group
it covers.
Sourcepub fn fetch_group(
&self,
key: u64,
options: impl Into<Option<Fetch>>,
) -> Pending<Fetching> ⓘ
pub fn fetch_group( &self, key: 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 Requests 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 key, or no Requests 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. A miss queues a one-group FillGroups,
which concurrent fetches of the same key join. A key past the live edge of a track fed
over lite-07 waits for the group, as a subscription would; the track’s own publisher
asks its Requests for it at once.
Sourcepub fn info(&self) -> Pending<Resolving> ⓘ
pub fn info(&self) -> Pending<Resolving> ⓘ
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.
Sourcepub fn poll_largest(&mut self, waiter: &Waiter) -> Poll<Option<Position>>
pub fn poll_largest(&mut self, waiter: &Waiter) -> Poll<Option<Position>>
The track’s largest location, its newest group at the newest frame (0 while empty):
the current one, then each newer one, and None once the track ends.
Sourcepub async fn largest(&mut self) -> Option<Position>
pub async fn largest(&mut self) -> Option<Position>
The track’s largest location, its newest group at the newest frame (0 while empty):
the current one, then each newer one, and None once the track ends.
Awaits poll_largest.