Skip to main content

ArcLocalStreamIds

Struct ArcLocalStreamIds 

Source
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>
where BLOCKED: SendFrame<StreamsBlockedFrame> + Clone + Send + 'static,

Source

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.

Source

pub fn role(&self) -> Role

Returns local role

Source

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.

Source

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.

Source

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.

Source

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>

Source§

fn clone(&self) -> ArcLocalStreamIds<BLOCKED>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<BLOCKED: Debug> Debug for ArcLocalStreamIds<BLOCKED>

Source§

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

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

impl<BLOCKED> ReceiveFrame<MaxStreamsFrame> for ArcLocalStreamIds<BLOCKED>
where BLOCKED: SendFrame<StreamsBlockedFrame> + Clone + Send + 'static,

Source§

type Output = ()

Source§

fn recv_frame(&self, frame: MaxStreamsFrame) -> Result<Self::Output, Error>

Receive the frames from the peer

Auto Trait Implementations§

§

impl<BLOCKED> Freeze for ArcLocalStreamIds<BLOCKED>

§

impl<BLOCKED> RefUnwindSafe for ArcLocalStreamIds<BLOCKED>

§

impl<BLOCKED> Send for ArcLocalStreamIds<BLOCKED>
where BLOCKED: Send,

§

impl<BLOCKED> Sync for ArcLocalStreamIds<BLOCKED>
where BLOCKED: Send,

§

impl<BLOCKED> Unpin for ArcLocalStreamIds<BLOCKED>

§

impl<BLOCKED> UnsafeUnpin for ArcLocalStreamIds<BLOCKED>

§

impl<BLOCKED> UnwindSafe for ArcLocalStreamIds<BLOCKED>

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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

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