Skip to main content

H2FlowControl

Struct H2FlowControl 

Source
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

Source

pub fn new() -> Self

Create a new flow-control tracker with the RFC default initial window.

Source

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.

Source

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.

Source

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.

Source

pub fn initial_window_size(&self) -> u32

The initial window size for new streams.

Source

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.

Source

pub fn peer_initial_window_size(&self) -> u32

The peer’s initial window size for new streams (send window).

Source

pub fn send_conn_window(&self) -> i64

The maximum number of bytes we can send on the connection right now.

Source

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.

Source

pub fn consume_send_conn_window(&mut self, n: u32)

Consume n bytes of the connection-level send window.

Trait Implementations§

Source§

impl Debug for H2FlowControl

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for H2FlowControl

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, _span: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ResponseProduces<T> for T