pub struct H2FlowControl { /* private fields */ }Expand description
Tracks HTTP/2 flow-control receive windows at connection and stream level.
The receiver (server) decrements windows when DATA frames arrive and sends WINDOW_UPDATE frames when enough data has been consumed to keep the sender from stalling.
Implementations§
Source§impl H2FlowControl
impl H2FlowControl
Sourcepub fn set_initial_window_size(&mut self, size: u32)
pub fn set_initial_window_size(&mut self, size: u32)
Update the initial window size (from SETTINGS_INITIAL_WINDOW_SIZE). This only affects future streams; the connection-level window is independent of this setting per RFC 7540 §6.9.2.
Sourcepub fn data_received_connection(&mut self, n: u32) -> u32
pub fn data_received_connection(&mut self, n: u32) -> u32
Record that n bytes of DATA payload were received on the connection.
Returns the connection-level WINDOW_UPDATE increment to send, or 0 if
no update is needed yet.
Sourcepub fn stream_window_update(&self, total_received: u32) -> u32
pub fn stream_window_update(&self, total_received: u32) -> u32
Compute a stream-level WINDOW_UPDATE increment after total_received
bytes have been received for a stream. Returns the increment to send,
or 0 if no update is needed.
For simplicity, the server sends a stream-level WINDOW_UPDATE when the consumed bytes exceed the threshold. Since streams are short-lived request bodies, we track this per-call rather than storing per-stream state.
Sourcepub fn initial_window_size(&self) -> u32
pub fn initial_window_size(&self) -> u32
The initial window size for new streams.
Sourcepub fn set_peer_initial_window_size(&mut self, size: u32)
pub fn set_peer_initial_window_size(&mut self, size: u32)
Set the peer’s initial window size (from peer’s SETTINGS_INITIAL_WINDOW_SIZE). This determines the send window for new streams.
Sourcepub fn peer_initial_window_size(&self) -> u32
pub fn peer_initial_window_size(&self) -> u32
The peer’s initial window size for new streams (send window).
Sourcepub fn send_conn_window(&self) -> i64
pub fn send_conn_window(&self) -> i64
The maximum number of bytes we can send on the connection right now.
Sourcepub fn peer_window_update_connection(&mut self, increment: u32)
pub fn peer_window_update_connection(&mut self, increment: u32)
Record a WINDOW_UPDATE received from the peer for the connection (stream_id == 0). Increases the connection-level send window.
Sourcepub fn consume_send_conn_window(&mut self, n: u32)
pub fn consume_send_conn_window(&mut self, n: u32)
Consume n bytes of the connection-level send window.