Struct h2::proto::streams::stream::Stream

source ·
pub(super) struct Stream {
Show 30 fields pub id: StreamId, pub state: State, pub is_counted: bool, pub ref_count: usize, pub next_pending_send: Option<Key>, pub is_pending_send: bool, pub send_flow: FlowControl, pub requested_send_capacity: u32, pub buffered_send_data: usize, send_task: Option<Waker>, pub pending_send: Deque, pub next_pending_send_capacity: Option<Key>, pub is_pending_send_capacity: bool, pub send_capacity_inc: bool, pub next_open: Option<Key>, pub is_pending_open: bool, pub is_pending_push: bool, pub next_pending_accept: Option<Key>, pub is_pending_accept: bool, pub recv_flow: FlowControl, pub in_flight_recv_data: u32, pub next_window_update: Option<Key>, pub is_pending_window_update: bool, pub reset_at: Option<Instant>, pub next_reset_expire: Option<Key>, pub pending_recv: Deque, pub is_recv: bool, pub recv_task: Option<Waker>, pub pending_push_promises: Queue<NextAccept>, pub content_length: ContentLength,
}
Expand description

Tracks Stream related state

§Reference counting

There can be a number of outstanding handles to a single Stream. These are tracked using reference counting. The ref_count field represents the number of outstanding userspace handles that can reach this stream.

It’s important to note that when the stream is placed in an internal queue (such as an accept queue), this is not tracked by a reference count. Thus, ref_count can be zero and the stream still has to be kept around.

Fields§

§id: StreamId

The h2 stream identifier

§state: State

Current state of the stream

§is_counted: bool

Set to true when the stream is counted against the connection’s max concurrent streams.

§ref_count: usize

Number of outstanding handles pointing to this stream

§next_pending_send: Option<Key>

Next node in the accept linked list

§is_pending_send: bool

Set to true when the stream is pending accept

§send_flow: FlowControl

Send data flow control

§requested_send_capacity: u32

Amount of send capacity that has been requested, but not yet allocated.

§buffered_send_data: usize

Amount of data buffered at the prioritization layer. TODO: Technically this could be greater than the window size…

§send_task: Option<Waker>

Task tracking additional send capacity (i.e. window updates).

§pending_send: Deque

Frames pending for this stream being sent to the socket

§next_pending_send_capacity: Option<Key>

Next node in the linked list of streams waiting for additional connection level capacity.

§is_pending_send_capacity: bool

True if the stream is waiting for outbound connection capacity

§send_capacity_inc: bool

Set to true when the send capacity has been incremented

§next_open: Option<Key>

Next node in the open linked list

§is_pending_open: bool

Set to true when the stream is pending to be opened

§is_pending_push: bool

Set to true when a push is pending for this stream

§next_pending_accept: Option<Key>

Next node in the accept linked list

§is_pending_accept: bool

Set to true when the stream is pending accept

§recv_flow: FlowControl

Receive data flow control

§in_flight_recv_data: u32§next_window_update: Option<Key>

Next node in the linked list of streams waiting to send window updates.

§is_pending_window_update: bool

True if the stream is waiting to send a window update

§reset_at: Option<Instant>

The time when this stream may have been locally reset.

§next_reset_expire: Option<Key>

Next node in list of reset streams that should expire eventually

§pending_recv: Deque

Frames pending for this stream to read

§is_recv: bool

When the RecvStream drop occurs, no data should be received.

§recv_task: Option<Waker>

Task tracking receiving frames

§pending_push_promises: Queue<NextAccept>

The stream’s pending push promises

§content_length: ContentLength

Validate content-length headers

Implementations§

source§

impl Stream

source

pub fn new(id: StreamId, init_send_window: u32, init_recv_window: u32) -> Stream

source

pub fn ref_inc(&mut self)

Increment the stream’s ref count

source

pub fn ref_dec(&mut self)

Decrements the stream’s ref count

source

pub fn is_pending_reset_expiration(&self) -> bool

Returns true if stream is currently being held for some time because of a local reset.

source

pub fn is_send_ready(&self) -> bool

Returns true if frames for this stream are ready to be sent over the wire

source

pub fn is_closed(&self) -> bool

Returns true if the stream is closed

source

pub fn is_released(&self) -> bool

Returns true if the stream is no longer in use

source

pub fn is_canceled_interest(&self) -> bool

Returns true when the consumer of the stream has dropped all handles (indicating no further interest in the stream) and the stream state is not actually closed.

In this case, a reset should be sent.

source

pub fn capacity(&self, max_buffer_size: usize) -> u32

Current available stream send capacity

source

pub fn assign_capacity(&mut self, capacity: u32, max_buffer_size: usize)

source

pub fn send_data(&mut self, len: u32, max_buffer_size: usize)

source

pub fn notify_capacity(&mut self)

If the capacity was limited because of the max_send_buffer_size, then consider waking the send task again…

source

pub fn dec_content_length(&mut self, len: usize) -> Result<(), ()>

Returns Err when the decrement cannot be completed due to overflow.

source

pub fn ensure_content_length_zero(&self) -> Result<(), ()>

source

pub fn notify_send(&mut self)

source

pub fn wait_send(&mut self, cx: &Context<'_>)

source

pub fn notify_recv(&mut self)

Trait Implementations§

source§

impl Debug for Stream

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Stream

§

impl RefUnwindSafe for Stream

§

impl Send for Stream

§

impl Sync for Stream

§

impl Unpin for Stream

§

impl UnwindSafe for Stream

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