Skip to main content

PeekedRecv

Struct PeekedRecv 

Source
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: Bytes

Bytes taken off inner before it was handed over, not yet handed to a reader.

Implementations§

Source§

impl PeekedRecv

Source

fn new(inner: RecvStream) -> Self

A stream nothing has been read from.

Source

fn with_prefix(inner: RecvStream, prefix: Bytes) -> Self

A stream prefix was read from, to be replayed before the rest.

Source

fn stream_id(&self) -> u64

Source

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.

Source

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.

Source

fn stop(&mut self, code: u64) -> Result<(), TransportError>

See RecvStream::stop. The unread prefix goes with everything else that was in flight.

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more