[][src]Struct h2::ReleaseCapacity

pub struct ReleaseCapacity { /* fields omitted */ }

A handle to release window capacity to a remote stream.

This type allows the caller to manage inbound data flow control. The caller is expected to call release_capacity after dropping data frames.

Overview

Each stream has a window size. This window size is the maximum amount of inbound data that can be in-flight. In-flight data is defined as data that has been received, but not yet released.

When a stream is created, the window size is set to the connection's initial window size value. When a data frame is received, the window size is then decremented by size of the data frame before the data is provided to the caller. As the caller finishes using the data, release_capacity must be called. This will then increment the window size again, allowing the peer to send more data.

There is also a connection level window as well as the stream level window. Received data counts against the connection level window as well and calls to release_capacity will also increment the connection level window.

Sending WINDOW_UPDATE frames

WINDOW_UPDATE frames will not be sent out for every call to release_capacity, as this would end up slowing down the protocol. Instead, h2 waits until the window size is increased to a certain threshold and then sends out a single WINDOW_UPDATE frame representing all the calls to release_capacity since the last WINDOW_UPDATE frame.

This essentially batches window updating.

Scenarios

Following is a basic scenario with an HTTP/2.0 connection containing a single active stream.

Methods

impl ReleaseCapacity[src]

pub fn stream_id(&self) -> StreamId[src]

Returns the stream ID of the stream whose capacity will be released by this ReleaseCapacity.

Panics

If the lock on the stream store has been poisoned.

pub fn release_capacity(&mut self, sz: usize) -> Result<(), Error>[src]

Release window capacity back to remote stream.

This releases capacity back to the stream level and the connection level windows. Both window sizes will be increased by sz.

See struct level documentation for more details.

Panics

This function panics if increasing the receive window size by sz would result in a window size greater than the target window size set by set_target_window_size. In other words, the caller cannot release more capacity than data has been received. If 1024 bytes of data have been received, at most 1024 bytes can be released.

Trait Implementations

impl Clone for ReleaseCapacity[src]

impl Debug for ReleaseCapacity[src]

Auto Trait Implementations

impl Send for ReleaseCapacity

impl Unpin for ReleaseCapacity

impl Sync for ReleaseCapacity

impl UnwindSafe for ReleaseCapacity

impl RefUnwindSafe for ReleaseCapacity

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]