pub struct ArcLocalStreamIds<BLOCKED>(/* private fields */);Expand description
Management of stream IDs that can ben allowed to use locally.
The maximum stream ID that can be created is limited by the
MaxStreamsFrame from the peer.
When the stream IDs in the dir direction are exhausted,
a StreamsBlockedFrame will be sent to the peer.
The generic parameter BLOCKED is the container of the StreamsBlockedFrame
that will be sent to peer, it can be a channel, a queue, or a buffer,
as long as it can send the StreamsBlockedFrame to peer.
Implementations§
Source§impl<BLOCKED> ArcLocalStreamIds<BLOCKED>
impl<BLOCKED> ArcLocalStreamIds<BLOCKED>
Sourcepub fn new(
role: Role,
max_bidi: u64,
max_uni: u64,
blocked: BLOCKED,
tx_wakers: ArcSendWakers,
) -> Self
pub fn new( role: Role, max_bidi: u64, max_uni: u64, blocked: BLOCKED, tx_wakers: ArcSendWakers, ) -> Self
Create a new ArcLocalStreamIds with the given role,
and maximum number of streams that can be created in each direction,
the blocked contains the StreamsBlockedFrame that will be sent to peer.
Sourcepub fn opened_streams(&self, dir: Dir) -> u64
pub fn opened_streams(&self, dir: Dir) -> u64
Returns the number of opened streams in the dir direction.
If is_0rtt is true, this will return the stream open in 0rtt phase.
If is_0rtt is false, the return value will not be greater than max_streams,
that is, if 0rtt is rejected, the return value may be less than the number of open streams.
This is the number of streams that can actually be sent in the 1rtt space.
Sourcepub fn recv_max_streams_frame(&self, frame: MaxStreamsFrame)
pub fn recv_max_streams_frame(&self, frame: MaxStreamsFrame)
Receive the MaxStreamsFrame from peer,
and then update the maximum stream ID that can be allowed to use locally.
The maximum stream ID that can be allowed to use is limited by peer.
Therefore, it mainly depends on the peer’s attitude
and is subject to the MaxStreamsFrame
received from peer.
Sourcepub fn poll_alloc_sid(
&self,
cx: &mut Context<'_>,
dir: Dir,
) -> Poll<Option<StreamId>>
pub fn poll_alloc_sid( &self, cx: &mut Context<'_>, dir: Dir, ) -> Poll<Option<StreamId>>
Asynchronously allocate the next new StreamId in the dir direction.
Return a bool indicating whether the stream is opened in 0rtt phase.
When the application layer wants to proactively open a new stream,
it needs to first apply to allocate the next unused StreamId.
Note that streams on a QUIC connection usually have a maximum concurrency limit,
so when requesting a StreamId, it may not be possible to obtain one due to
reaching the maximum concurrency limit.
However, this is temporary. When the active current streams end,
the peer will expand the maximum stream ID limit through a
MaxStreamsFrame,
allowing the allocation of the StreamId meanwhile.
Return Pending when the stream IDs in the dir direction are exhausted,
until receiving the MaxStreamsFrame from peer.
Return None if the stream IDs in the dir direction finally exceed 2^60,
but it is very very hard to happen.
pub fn revise_max_streams( &self, zero_rtt_rejected: bool, max_stream_bidi: u64, max_stream_uni: u64, )
Trait Implementations§
Source§impl<BLOCKED: Clone> Clone for ArcLocalStreamIds<BLOCKED>
impl<BLOCKED: Clone> Clone for ArcLocalStreamIds<BLOCKED>
Source§fn clone(&self) -> ArcLocalStreamIds<BLOCKED>
fn clone(&self) -> ArcLocalStreamIds<BLOCKED>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more