pub struct Demand { /* private fields */ }Expand description
A cloneable, watch-only handle to a track’s subscriber demand.
Obtained from Producer::demand, Request::demand, or Requests::demand.
A publisher uses it to learn which group anyone subscribed, querying, or fetching
wants (on-demand capture / encoding) without being able to publish frames or close the
track. A bare Consumer is not demand. A group a subscription or fetch handed out
keeps its track wanted until a reader reads its end, and a wanted track makes its
broadcast wanted (broadcast::Demand). It’s a weak handle, so it neither keeps
the track alive nor pins its cached groups; once the owning Producer
goes away, poll_wanted_changed reports the track’s
closure. 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 anyone consumes the open track: a subscription, query, fetch, or a group one of them handed out and a reader has not finished.
Sourcepub fn poll_wanted_changed(&mut self, waiter: &Waiter) -> Poll<Result<bool>>
pub fn poll_wanted_changed(&mut self, waiter: &Waiter) -> Poll<Result<bool>>
wanted once it differs from what this handle last returned:
immediately on the first call, then on each change. Errors once the track is closed
or aborted.
So while demand.wanted_changed().await? {} runs while anyone wants the track, and
while !demand.wanted_changed().await? {} waits for someone to. End a track nobody
wants by dropping its Producer: a reader that joined since is served by the next
request for it.
Sourcepub async fn wanted_changed(&mut self) -> Result<bool>
pub async fn wanted_changed(&mut self) -> Result<bool>
wanted once it differs from what this handle last returned:
immediately on the first call, then on each change. Errors once the track is closed
or aborted.
So while demand.wanted_changed().await? {} runs while anyone wants the track, and
while !demand.wanted_changed().await? {} waits for someone to. End a track nobody
wants by dropping its Producer: a reader that joined since is served by the next
request for it.
Awaits poll_wanted_changed.
Sourcepub fn poll_refresh(&self, waiter: &Waiter) -> Poll<Result<()>>
pub fn poll_refresh(&self, waiter: &Waiter) -> Poll<Result<()>>
Ready while a consumer asks for a new group: the first group of a track with none
written, or a live join or Subscriber::refresh judged by Info::refresh, once
its interval has passed. The next group appended answers it, so a publisher waits
here, opens a group (a keyframe or a snapshot), and waits again. Errors once the track
is closed or aborted.
Sourcepub async fn refresh(&self) -> Result<()>
pub async fn refresh(&self) -> Result<()>
Ready while a consumer asks for a new group: the first group of a track with none
written, or a live join or Subscriber::refresh judged by Info::refresh, once
its interval has passed. The next group appended answers it, so a publisher waits
here, opens a group (a keyframe or a snapshot), and waits again. Errors once the track
is closed or aborted.
Awaits poll_refresh.
Sourcepub fn poll_closed(&self, waiter: &Waiter) -> Poll<Result<()>>
pub fn poll_closed(&self, waiter: &Waiter) -> Poll<Result<()>>
Resolves once the track’s outcome is final; see Producer::poll_closed.
Sourcepub async fn closed(&self) -> Result<()>
pub async fn closed(&self) -> Result<()>
Resolves once the track’s outcome is final; see Producer::poll_closed.
Awaits poll_closed.