pub struct UnorderedRecvStream { /* private fields */ }Expand description
A stream that can be used to receive data out-of-order.
Obtained by converting a RecvStream via RecvStream::into_unordered.
This variant of RecvStream allows reading chunks of data exclusively
out of order. Once you have done an unordered read, ordered reads are no
longer possible since data may have been consumed out of order.
The stream state related fns like Self::id, Self::is_0rtt, Self::stop, and
Self::received_reset behave exactly as on RecvStream.
Implementations§
Source§impl UnorderedRecvStream
impl UnorderedRecvStream
Sourcepub async fn read_chunk(
&mut self,
max_length: usize,
) -> Result<Option<Chunk>, ReadError>
pub async fn read_chunk( &mut self, max_length: usize, ) -> Result<Option<Chunk>, ReadError>
Reads the next segment of data.
Yields None if the stream was finished. Otherwise, yields a segment of data and its
offset in the stream. Segments may be received in any order, and the Chunk’s offset
field can be used to determine ordering in the caller. Unordered reads are less prone
to head-of-line blocking within a stream, but require the application to manage
reassembling the original data.
This operation is cancel-safe.
Sourcepub fn is_0rtt(&self) -> bool
pub fn is_0rtt(&self) -> bool
Check if this stream has been opened during 0-RTT.
In which case any non-idempotent request should be considered dangerous at the application level. Because read data is subject to replay attacks.
Sourcepub fn stop(&mut self, error_code: VarInt) -> Result<(), ClosedStream>
pub fn stop(&mut self, error_code: VarInt) -> Result<(), ClosedStream>
Stop accepting data
Discards unread data and notifies the peer to stop transmitting. Once stopped, further
attempts to operate on a stream will yield ClosedStream errors.
Sourcepub async fn received_reset(&mut self) -> Result<Option<VarInt>, ResetError>
pub async fn received_reset(&mut self) -> Result<Option<VarInt>, ResetError>
Completes when the stream has been reset by the peer or otherwise closed
Yields Some with the reset error code when the stream is reset by the peer. Yields None
when the stream was previously stop()ed, or when the stream was
finish()ed by the peer and all data has been received, after
which it is no longer meaningful for the stream to be reset.
This operation is cancel-safe.