pub trait ControlStreamsConcurrency:
Debug
+ Send
+ Sync {
// Required methods
fn on_accept_streams(&mut self, dir: Dir, sid: u64) -> Option<u64>;
fn on_end_of_stream(&mut self, dir: Dir, sid: u64) -> Option<u64>;
fn on_streams_blocked(&mut self, dir: Dir, max_streams: u64) -> Option<u64>;
}
Expand description
Controls the concurrency of unidirectional and bidirectional streams created by the peer,
primarily through StreamsBlockedFrame
and MaxStreamsFrame
.
RFC 9000 leaves implementations to decide when and how many streams should be advertised to a peer via MAX_STREAMS. Implementations might choose to increase limits as streams are closed, to keep the number of streams available to peers roughly consistent.
Implementations might also choose to increase limits as long as the peer needs to create new streams.
See controlling concurrency. of QUIC for more details.
Required Methods§
Sourcefn on_accept_streams(&mut self, dir: Dir, sid: u64) -> Option<u64>
fn on_accept_streams(&mut self, dir: Dir, sid: u64) -> Option<u64>
Called back upon accepting a new dir
direction streams with stream id sid
from peer,
all previous inexistent dir
direction streams should be opened by peer will also be created.
Returns whether to increase the maximum stream ID limit, which will be communicated to the peer via a MAX_STREAMS frame in the future. If None is returned, it means there is no need to increase the MAX_STREAMS for the time being.
Sourcefn on_end_of_stream(&mut self, dir: Dir, sid: u64) -> Option<u64>
fn on_end_of_stream(&mut self, dir: Dir, sid: u64) -> Option<u64>
Called back upon a dir
directional stream is ended,
whether it is closed normally or reset abnormally.
The sid
is the stream ID of the ended dir
direction stream.
Returns whether to increase the maximum stream ID limit, which will be communicated to the peer via a MAX_STREAMS frame in the future. If None is returned, it means there is no need to increase the MAX_STREAMS for the time being.
Sourcefn on_streams_blocked(&mut self, dir: Dir, max_streams: u64) -> Option<u64>
fn on_streams_blocked(&mut self, dir: Dir, max_streams: u64) -> Option<u64>
Called back upon receiving the StreamsBlocked frame,
which indicates that the peer is limited to create more dir
direction streams.
It may optionally return an increased value for the max_streams
for the dir
directional streams.
If None is returned, it means there is no need to increase
the MAX_STREAMS for the time being.