pub struct Consumer { /* private fields */ }Expand description
Subscribe to arbitrary broadcast/tracks.
Implementations§
Source§impl Consumer
impl Consumer
Sourcepub fn poll_route_changed(
&mut self,
waiter: &Waiter,
) -> Poll<Result<Route, Error>>
pub fn poll_route_changed( &mut self, waiter: &Waiter, ) -> Poll<Result<Route, Error>>
Poll for a route change. See Self::route_changed.
Sourcepub async fn route_changed(&mut self) -> Result<Route, Error>
pub async fn route_changed(&mut self) -> Result<Route, Error>
Wait for the broadcast’s Route to change.
The first call returns the current route immediately; each later call blocks
until it changes again, so a loop observes the initial value followed by
every update. Returns Error::Dropped once every producer is gone.
Sourcepub fn track(&self, name: &str) -> Result<Consumer, Error>
pub fn track(&self, name: &str) -> Result<Consumer, Error>
Get a handle to a track on this broadcast.
Sourcepub fn demand(&self) -> Demand
pub fn demand(&self) -> Demand
A watch-only handle to the broadcast’s demand. See Demand.
The consumer-side sibling of Producer::demand, for a holder that has
only a read handle: a relay pulling a broadcast from upstream owns no
producer for it (the ingesting session does), yet the question it has to
answer is whether anything downstream is still reading. Holding this
handle, or the Consumer it came from, is not itself demand.
Two endings a caller has to tell apart. Demand going away is
Demand::unused resolving, and means nobody downstream is reading.
The broadcast going away is Error::Dropped, and here that is the
upstream producer, not the readers.
Sourcepub async fn closed(&self) -> Error
pub async fn closed(&self) -> Error
Block until the broadcast is closed, by Producer::finish,
Producer::abort, or every producer dropping, and return the cause.
Returns the error passed to Producer::abort, or Error::Dropped for a
Producer::finish or a dropped producer (check Self::is_finished to
tell those apart).
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Whether the broadcast ended via a deliberate Producer::finish, as opposed
to aborting or losing its producer. false while the broadcast is still live;
an origin uses this to close a front immediately on a deliberate end instead
of lingering for a replacement.
Sourcepub fn poll_closed(&self, waiter: &Waiter) -> Poll<()>
pub fn poll_closed(&self, waiter: &Waiter) -> Poll<()>
Register a kio::Waiter that fires when the broadcast closes.
Returns Poll::Ready if already closed, otherwise Poll::Pending after
arming the waiter. Useful for composing close-detection into a larger poll
without spawning a task per broadcast.