struct PeekedRecv {
inner: RecvStream,
prefix: Bytes,
}Expand description
A receive stream with bytes already taken off it.
Nothing says what a unidirectional stream is for until its first varint has been read, and reading it consumes it. The classifier hands those bytes back here, and the pipe that takes the stream reads them first and the transport afterwards, so a stream that was classified is indistinguishable from one that was not.
On drafts whose streams are never classified the prefix is empty and this
is a RecvStream with one extra branch on the read path.
Fields§
§inner: RecvStream§prefix: BytesBytes taken off inner before it was handed over, not yet handed to
a reader.
Implementations§
Source§impl PeekedRecv
impl PeekedRecv
Sourcefn new(inner: RecvStream) -> Self
fn new(inner: RecvStream) -> Self
A stream nothing has been read from.
Sourcefn with_prefix(inner: RecvStream, prefix: Bytes) -> Self
fn with_prefix(inner: RecvStream, prefix: Bytes) -> Self
A stream prefix was read from, to be replayed before the rest.
Sourceasync fn read(
&mut self,
buf: &mut [u8],
) -> Result<Option<usize>, TransportError>
async fn read( &mut self, buf: &mut [u8], ) -> Result<Option<usize>, TransportError>
See RecvStream::read, with the replayed prefix ahead of it.
Cancel-safe for the same reason RecvStream::read is, and the prefix
branch adds nothing to worry about: it awaits nothing, so it either
runs to completion on its first poll or is never entered at all.
Sourceasync fn received_reset(&mut self) -> Result<Option<u64>, TransportError>
async fn received_reset(&mut self) -> Result<Option<u64>, TransportError>
See RecvStream::received_reset.
Not affected by the prefix: a peer’s RESET_STREAM is about the
stream, and bytes already taken off it were taken before it was sent.
Sourcefn stop(&mut self, code: u64) -> Result<(), TransportError>
fn stop(&mut self, code: u64) -> Result<(), TransportError>
See RecvStream::stop. The unread prefix goes with everything else
that was in flight.