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
impl Stream
pub fn new(id: StreamId, init_send_window: u32, init_recv_window: u32) -> Stream
sourcepub fn is_pending_reset_expiration(&self) -> bool
pub fn is_pending_reset_expiration(&self) -> bool
Returns true if stream is currently being held for some time because of a local reset.
sourcepub fn is_send_ready(&self) -> bool
pub fn is_send_ready(&self) -> bool
Returns true if frames for this stream are ready to be sent over the wire
sourcepub fn is_released(&self) -> bool
pub fn is_released(&self) -> bool
Returns true if the stream is no longer in use
sourcepub fn is_canceled_interest(&self) -> bool
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.
pub fn assign_capacity(&mut self, capacity: u32, max_buffer_size: usize)
pub fn send_data(&mut self, len: u32, max_buffer_size: usize)
sourcepub fn notify_capacity(&mut self)
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…
sourcepub fn dec_content_length(&mut self, len: usize) -> Result<(), ()>
pub fn dec_content_length(&mut self, len: usize) -> Result<(), ()>
Returns Err
when the decrement cannot be completed due to overflow.