pub struct Consumer { /* private fields */ }Expand description
Consumes bandwidth estimates, allowing reads and async change notifications.
Implementations§
Source§impl Consumer
impl Consumer
Sourcepub fn probed(&self) -> bool
pub fn probed(&self) -> bool
Whether a session probes the connection for this slice’s reservation, so the estimate can rise to fund it even while its sender is stopped.
Only a session whose transport has a sender probes, and none does for it while
Allocator::set_target overrides the target to zero. For a Viewer’s slice,
whether the session asks a peer that advertised Increase to probe for it, which
Viewers::set_target can turn off the same way. Without one the estimate
stops learning once the connection is app-limited, so a sender that stops for
lack of bandwidth could never see enough to resume. Always false for a whole
estimate, which no reservation backs. poll_changed
reports a change to this too.
Sourcepub fn poll_changed(&mut self, waiter: &Waiter) -> Poll<Result<Option<Rate>>>
pub fn poll_changed(&mut self, waiter: &Waiter) -> Poll<Result<Option<Rate>>>
The bandwidth estimate once it changes, or None when it has become unavailable.
Ok(None) means the estimate is unavailable for now: the backend
stopped reporting one, or the handle spans reconnects and is between
sessions. Err means the producer is gone and no further change will ever
arrive. They’re distinct because a caller holds its current rate for the
first and stops watching for the second.
A slice is also reported, unchanged, when probed flips.
A backend with no bandwidth estimation at all yields no Consumer in the first place, so that case never reaches here.
Sourcepub async fn changed(&mut self) -> Result<Option<Rate>>
pub async fn changed(&mut self) -> Result<Option<Rate>>
The bandwidth estimate once it changes, or None when it has become unavailable.
Ok(None) means the estimate is unavailable for now: the backend
stopped reporting one, or the handle spans reconnects and is between
sessions. Err means the producer is gone and no further change will ever
arrive. They’re distinct because a caller holds its current rate for the
first and stops watching for the second.
A slice is also reported, unchanged, when probed flips.
A backend with no bandwidth estimation at all yields no Consumer in the first place, so that case never reaches here.
Awaits poll_changed.