Struct h2::proto::streams::flow_control::FlowControl

source ·
pub struct FlowControl {
    window_size: Window,
    available: Window,
}

Fields§

§window_size: Window

Window the peer knows about.

This can go negative if a SETTINGS_INITIAL_WINDOW_SIZE is received.

For example, say the peer sends a request and uses 32kb of the window. We send a SETTINGS_INITIAL_WINDOW_SIZE of 16kb. The peer has to adjust its understanding of the capacity of the window, and that would be:

default (64kb) - used (32kb) - settings_diff (64kb - 16kb): -16kb
§available: Window

Window that we know about.

This can go negative if a user declares a smaller target window than the peer knows about.

Implementations§

source§

impl FlowControl

source

pub fn new() -> FlowControl

source

pub fn window_size(&self) -> u32

Returns the window size as known by the peer

source

pub fn available(&self) -> Window

Returns the window size available to the consumer

source

pub fn has_unavailable(&self) -> bool

Returns true if there is unavailable window capacity

source

pub fn claim_capacity(&mut self, capacity: u32) -> Result<(), Reason>

source

pub fn assign_capacity(&mut self, capacity: u32) -> Result<(), Reason>

source

pub fn unclaimed_capacity(&self) -> Option<u32>

If a WINDOW_UPDATE frame should be sent, returns a positive number representing the increment to be used.

If there is no available bytes to be reclaimed, or the number of available bytes does not reach the threshold, this returns None.

This represents pending outbound WINDOW_UPDATE frames.

source

pub fn inc_window(&mut self, sz: u32) -> Result<(), Reason>

Increase the window size.

This is called after receiving a WINDOW_UPDATE frame

source

pub fn dec_send_window(&mut self, sz: u32) -> Result<(), Reason>

Decrement the send-side window size.

This is called after receiving a SETTINGS frame with a lower INITIAL_WINDOW_SIZE value.

source

pub fn dec_recv_window(&mut self, sz: u32) -> Result<(), Reason>

Decrement the recv-side window size.

This is called after receiving a SETTINGS ACK frame with a lower INITIAL_WINDOW_SIZE value.

source

pub fn send_data(&mut self, sz: u32) -> Result<(), Reason>

Decrements the window reflecting data has actually been sent. The caller must ensure that the window has capacity.

Trait Implementations§

source§

impl Clone for FlowControl

source§

fn clone(&self) -> FlowControl

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for FlowControl

source§

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

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

impl Copy for FlowControl

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: 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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