pub struct StreamSlotMap { /* private fields */ }Expand description
A synchronous stream demultiplexer with explicit ownership transfer on reads.
Implementations§
Source§impl StreamSlotMap
impl StreamSlotMap
Sourcepub const fn new(limits: StreamLimits) -> Self
pub const fn new(limits: StreamLimits) -> Self
Creates a client map. Zero limits intentionally disable buffering.
Sourcepub const fn with_role(limits: StreamLimits, role: EndpointRole) -> Self
pub const fn with_role(limits: StreamLimits, role: EndpointRole) -> Self
Creates an empty map for the specified local HTTP/2 endpoint role.
Sourcepub fn open_stream(&mut self, stream_id: i32) -> SlotResult<()>
pub fn open_stream(&mut self, stream_id: i32) -> SlotResult<()>
Opens a stream without allocating receive buffers.
§Errors
Rejects invalid/existing identifiers and new local streams after GOAWAY.
Sourcepub fn get(&self, stream_id: i32) -> Option<&StreamSlot>
pub fn get(&self, stream_id: i32) -> Option<&StreamSlot>
Looks up a stream without consuming events.
Sourcepub fn active_stream_count(&self) -> usize
pub fn active_stream_count(&self) -> usize
Number of retained stream slots, including closed slots awaiting removal.
Sourcepub const fn goaway(&self) -> Option<(i32, u32)>
pub const fn goaway(&self) -> Option<(i32, u32)>
Most restrictive GOAWAY boundary and its associated HTTP/2 error code.
Sourcepub fn push_initial_metadata(
&mut self,
stream_id: i32,
headers: Headers,
) -> SlotResult<()>
pub fn push_initial_metadata( &mut self, stream_id: i32, headers: Headers, ) -> SlotResult<()>
Stores the initial header block exactly once, even after it is consumed.
§Errors
Rejects unknown/reset streams, duplicate or late headers, and budget excess.
Sourcepub fn append_recv_bytes(
&mut self,
stream_id: i32,
bytes: &[u8],
) -> SlotResult<()>
pub fn append_recv_bytes( &mut self, stream_id: i32, bytes: &[u8], ) -> SlotResult<()>
Accepts arbitrary DATA fragmentation and queues complete gRPC envelopes.
§Errors
Rejects missing headers, ended/reset streams, malformed flags or excess resources. Rejections preserve accepted frames and partial bytes.
Sourcepub fn push_message(
&mut self,
stream_id: i32,
message: StreamMessage,
) -> SlotResult<()>
pub fn push_message( &mut self, stream_id: i32, message: StreamMessage, ) -> SlotResult<()>
Queues a complete envelope supplied by an upstream frame decoder.
§Errors
Rejects missing headers, ended/reset streams, partial frames or excess resources.
Sourcepub fn push_trailing_metadata(
&mut self,
stream_id: i32,
headers: Headers,
) -> SlotResult<()>
pub fn push_trailing_metadata( &mut self, stream_id: i32, headers: Headers, ) -> SlotResult<()>
Stores trailers or a Trailers-Only response; mark END_STREAM separately.
§Errors
Rejects ended/reset streams, duplicate trailers, partial frames or excess resources.
Sourcepub fn mark_remote_end_stream(&mut self, stream_id: i32) -> SlotResult<()>
pub fn mark_remote_end_stream(&mut self, stream_id: i32) -> SlotResult<()>
Closes the peer’s sending half; request streams need not carry trailers.
§Errors
Rejects unknown/reset streams, duplicate END_STREAM and truncated envelopes.
Sourcepub fn mark_local_end_stream(&mut self, stream_id: i32) -> SlotResult<()>
pub fn mark_local_end_stream(&mut self, stream_id: i32) -> SlotResult<()>
Closes the local sending half independently of the receive queues.
§Errors
Rejects unknown/reset streams or duplicate local END_STREAM.
Sourcepub fn record_rst_stream(
&mut self,
stream_id: i32,
error_code: u32,
) -> SlotResult<()>
pub fn record_rst_stream( &mut self, stream_id: i32, error_code: u32, ) -> SlotResult<()>
Closes both halves, preserving completed responses for NO_ERROR resets.
§Errors
Rejects unknown streams and repeated resets, preserving the first code.
Sourcepub fn apply_goaway(
&mut self,
last_stream_id: i32,
error_code: u32,
) -> SlotResult<Vec<i32>>
pub fn apply_goaway( &mut self, last_stream_id: i32, error_code: u32, ) -> SlotResult<Vec<i32>>
Prunes excluded local streams; peer-initiated streams remain unaffected. Repeated GOAWAY frames can only reduce the accepted stream boundary.
§Errors
Rejects negative boundaries and increases to an established boundary.
Sourcepub fn pop_initial_metadata(
&mut self,
stream_id: i32,
) -> SlotResult<Option<Headers>>
pub fn pop_initial_metadata( &mut self, stream_id: i32, ) -> SlotResult<Option<Headers>>
Transfers initial metadata ownership, leaving lifecycle history intact.
§Errors
Rejects unknown streams or resets other than completed-response NO_ERROR.
Sourcepub fn pop_message(
&mut self,
stream_id: i32,
) -> SlotResult<Option<StreamMessage>>
pub fn pop_message( &mut self, stream_id: i32, ) -> SlotResult<Option<StreamMessage>>
Transfers the next message in stream order and releases its byte charge.
§Errors
Rejects unknown streams or resets other than completed-response NO_ERROR.
Sourcepub fn take_trailers(&mut self, stream_id: i32) -> SlotResult<Option<Headers>>
pub fn take_trailers(&mut self, stream_id: i32) -> SlotResult<Option<Headers>>
Transfers trailers exactly once without changing the remote half state.
§Errors
Rejects unknown streams or resets other than completed-response NO_ERROR.
Sourcepub fn remove_closed_stream(&mut self, stream_id: i32) -> SlotResult<StreamSlot>
pub fn remove_closed_stream(&mut self, stream_id: i32) -> SlotResult<StreamSlot>
Removes a reset or fully closed stream, including any unread events.
§Errors
Rejects unknown streams and streams with an open sending half.