pub struct Demand { /* private fields */ }Expand description
A cloneable, watch-only handle to whether anyone reads a broadcast.
Obtained from Producer::demand. The broadcast is wanted while any of its tracks is
(track::Demand::wanted is Some) or a track request waits for a Requests
handler, so a publisher can follow its readers without holding every track’s producer.
It’s a weak handle: it neither keeps the broadcast alive nor counts as demand.
Each clone watches on its own, so its first
poll_wanted_changed reports the current value.
Implementations§
Source§impl Demand
impl Demand
Sourcepub fn wanted(&self) -> bool
pub fn wanted(&self) -> bool
Whether the broadcast is open and any of its tracks is wanted or requested right now.
Sourcepub fn poll_wanted_changed(
&mut self,
waiter: &Waiter,
) -> Poll<Result<bool, Error>>
pub fn poll_wanted_changed( &mut self, waiter: &Waiter, ) -> Poll<Result<bool, Error>>
Resolves to wanted once it differs from what this handle last
returned: immediately on the first call, then on each change. Errors once the
broadcast closes.
So while !demand.wanted_changed().await? {} waits for a reader, and
while demand.wanted_changed().await? {} waits for the last one to leave.
Sourcepub async fn wanted_changed(&mut self) -> Result<bool, Error>
pub async fn wanted_changed(&mut self) -> Result<bool, Error>
Resolves to wanted once it differs from what this handle last
returned: immediately on the first call, then on each change. Errors once the
broadcast closes.
So while !demand.wanted_changed().await? {} waits for a reader, and
while demand.wanted_changed().await? {} waits for the last one to leave.
Awaits poll_wanted_changed.