Change ReserveCapacity to expanded FlowControl type (#423)

- Adds `FlowControl::available_capacity` method.
- Adds `FlowControl::used_capacity` method.
This commit is contained in:
Sean McArthur
2019-10-08 11:28:15 -07:00
committed by GitHub
parent 3cfcab016e
commit 86e53054a6
7 changed files with 98 additions and 76 deletions

View File

@@ -1187,6 +1187,22 @@ impl OpaqueStreamRef {
me.actions.recv.poll_trailers(cx, &mut stream)
}
pub(crate) fn available_recv_capacity(&self) -> isize {
let me = self.inner.lock().unwrap();
let me = &*me;
let stream = &me.store[self.key];
stream.recv_flow.available().into()
}
pub(crate) fn used_recv_capacity(&self) -> WindowSize {
let me = self.inner.lock().unwrap();
let me = &*me;
let stream = &me.store[self.key];
stream.in_flight_recv_data
}
/// Releases recv capacity back to the peer. This may result in sending
/// WINDOW_UPDATE frames on both the stream and connection.
pub fn release_capacity(&mut self, capacity: WindowSize) -> Result<(), UserError> {