pub struct Request { /* private fields */ }Expand description
A subscriber asked for a track this broadcast doesn’t have yet.
Yielded by broadcast::Dynamic::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 dynamic(&self) -> Dynamic
pub fn dynamic(&self) -> Dynamic
Create a Dynamic 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 poll_unused(&self, waiter: &Waiter) -> Poll<()>
pub fn poll_unused(&self, waiter: &Waiter) -> Poll<()>
Poll for the request becoming unused (every consumer dropped), so a relay can stop serving and drop the request.
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). If the track was already aborted, 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 async fn subscription_changed(&mut self) -> Option<Subscription>
pub async fn subscription_changed(&mut self) -> Option<Subscription>
Block until the aggregate subscription changes,
yielding None once nobody is waiting.
Sourcepub fn poll_subscription_changed(
&mut self,
waiter: &Waiter,
) -> Poll<Option<Subscription>>
pub fn poll_subscription_changed( &mut self, waiter: &Waiter, ) -> Poll<Option<Subscription>>
Poll counterpart to subscription_changed.