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

@@ -118,7 +118,7 @@
use crate::codec::{Codec, RecvError, UserError};
use crate::frame::{self, Pseudo, PushPromiseHeaderError, Reason, Settings, StreamId};
use crate::proto::{self, Config, Prioritized};
use crate::{PingPong, RecvStream, ReleaseCapacity, SendStream};
use crate::{FlowControl, PingPong, RecvStream, SendStream};
use bytes::{Buf, Bytes, IntoBuf};
use http::{HeaderMap, Request, Response};
@@ -408,7 +408,7 @@ where
if let Some(inner) = self.connection.next_incoming() {
log::trace!("received incoming");
let (head, _) = inner.take_request().into_parts();
let body = RecvStream::new(ReleaseCapacity::new(inner.clone_to_opaque()));
let body = RecvStream::new(FlowControl::new(inner.clone_to_opaque()));
let request = Request::from_parts(head, body);
let respond = SendResponse { inner };
@@ -427,14 +427,14 @@ where
///
/// If `size` is less than the current value, nothing will happen
/// immediately. However, as window capacity is released by
/// [`ReleaseCapacity`] instances, no `WINDOW_UPDATE` frames will be sent
/// [`FlowControl`] instances, no `WINDOW_UPDATE` frames will be sent
/// out until the number of "in flight" bytes drops below `size`.
///
/// The default value is 65,535.
///
/// See [`ReleaseCapacity`] documentation for more details.
/// See [`FlowControl`] documentation for more details.
///
/// [`ReleaseCapacity`]: ../struct.ReleaseCapacity.html
/// [`FlowControl`]: ../struct.FlowControl.html
/// [library level]: ../index.html#flow-control
pub fn set_target_window_size(&mut self, size: u32) {
assert!(size <= proto::MAX_WINDOW_SIZE);
@@ -591,11 +591,11 @@ impl Builder {
/// flow control for received data.
///
/// The initial window of a stream is used as part of flow control. For more
/// details, see [`ReleaseCapacity`].
/// details, see [`FlowControl`].
///
/// The default value is 65,535.
///
/// [`ReleaseCapacity`]: ../struct.ReleaseCapacity.html
/// [`FlowControl`]: ../struct.FlowControl.html
///
/// # Examples
///
@@ -625,11 +625,11 @@ impl Builder {
/// for received data.
///
/// The initial window of a connection is used as part of flow control. For more details,
/// see [`ReleaseCapacity`].
/// see [`FlowControl`].
///
/// The default value is 65,535.
///
/// [`ReleaseCapacity`]: ../struct.ReleaseCapacity.html
/// [`FlowControl`]: ../struct.FlowControl.html
///
/// # Examples
///