pub struct Request { /* private fields */ }Expand description
A subscriber asked for a track this broadcast doesn’t have yet.
Yielded by poll_requested_track,
or created up front with broadcast::Producer::reserve_track.
Subscribers block until the request is
resolved: call accept to serve it with a Producer, or
reject to fail them. Dropping it without either rejects with
Error::Dropped.
Concurrent requests for one name are coalesced, so exactly one of these exists per name at a time.
Implementations§
Source§impl Request
impl Request
Sourcepub fn consume(&self) -> Consumer
pub fn consume(&self) -> Consumer
A Consumer for the eventual track, usable before the request is accepted.
Sourcepub fn requests(&self) -> Requests
pub fn requests(&self) -> Requests
Create a Requests handle that serves on-demand fetches of uncached
groups, before Self::accept is even called. A relay creates one to fetch
past groups from upstream while (or instead of) serving a live subscription.
Sourcepub fn accept(self, info: impl Into<Option<Info>>) -> Producer
pub fn accept(self, info: impl Into<Option<Info>>) -> Producer
Serve the request with the given track, resolving every waiting subscriber.
The name is taken from Self::name; info supplies the remaining knobs
(None for the defaults). A track asked for again because its last producer dropped
while read must be accepted with the info it was first accepted with, which its
readers already hold: a different info aborts the track with Error::MalformedTrack,
so those readers end and a later lookup asks for the track afresh. Such a track also
keeps the groups its last producer finished, so continue past them, as
Producer::append_group does, rather than numbering from zero again. If the track was
already aborted, or is aborted that way, the returned Producer is inert: writes
fail with the abort error, as if it had been aborted immediately after accepting.
Sourcepub fn subscription(&self) -> Option<Subscription>
pub fn subscription(&self) -> Option<Subscription>
The delivery preferences aggregated across everyone waiting on this request,
or None if nobody is waiting. Useful for sizing the track before accepting.
Sourcepub fn poll_subscription_changed(
&mut self,
waiter: &Waiter,
) -> Poll<Option<Subscription>>
pub fn poll_subscription_changed( &mut self, waiter: &Waiter, ) -> Poll<Option<Subscription>>
The aggregate subscription once it changes, or None once
nobody is waiting.
Sourcepub async fn subscription_changed(&mut self) -> Option<Subscription>
pub async fn subscription_changed(&mut self) -> Option<Subscription>
The aggregate subscription once it changes, or None once
nobody is waiting.
Awaits poll_subscription_changed.