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 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.
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), or the track’s abort error
if it’s already closed. Concurrent fetches for the same sequence coalesce onto one
handler request.
Sourcepub fn info(&self) -> Pending<Querying>
pub fn info(&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.