Skip to main content

RecvStream

Enum RecvStream 

Source
pub enum RecvStream {
    Quic(RecvStream),
}
Expand description

A transport-agnostic receive stream.

Variants§

§

Quic(RecvStream)

Raw QUIC receive stream.

Implementations§

Source§

impl RecvStream

Source

pub fn stream_id(&self) -> u64

Get the QUIC stream ID (transport-level identifier).

Source

pub async fn read( &mut self, buf: &mut [u8], ) -> Result<Option<usize>, TransportError>

Read data into the buffer. Returns Ok(Some(n)) with bytes read, Ok(None) on stream end, or Err on failure.

Fails with TransportError::StreamReset carrying the peer’s application error code if the peer reset the stream, which is how callers distinguish an abandoned stream from a clean FIN (Ok(None)).

Source

pub async fn received_reset(&mut self) -> Result<Option<u64>, TransportError>

Wait for the peer to reset this stream — without reading a byte.

read is the only other way to learn that a peer sent RESET_STREAM, and it is unusable by a reader that has stopped consuming on purpose: a forwarder applying backpressure holds its source unread, so the reset surfaces on a call it is deliberately not making, and the abandonment goes unobserved for as long as the backpressure lasts. This observes the same event on its own.

It consumes nothing. No bytes leave the receive buffer, so no MAX_STREAM_DATA credit is granted and the peer stays flow-control blocked exactly as it was. That is the whole point: it is safe to poll while backpressure is being applied, which read is not.

Cancel-safe: it registers interest and consumes no state, so dropping the future loses nothing.

§Returns
  • Ok(Some(code)) — the peer reset the stream with this application error code. The same code TransportError::StreamReset would have carried out of read.
  • Ok(None)no reset is observable on this stream, now or ever, and the caller must stop asking: this resolves immediately every time, so a caller that re-polls it in a loop spins. Either the transport freed the stream’s state (it was finished and fully read, or stopped) or, on the WebTransport arm, wtransport exposes no reset-only observable at all and this answers Ok(None) unconditionally.
  • Err — a connection-level failure.
Source

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

Stop accepting data on the stream, discarding anything unread and telling the peer to stop transmitting with code as the STOP_SENDING application error code.

Dropping a RecvStream also stops it, but with a hard-coded code of 0 — so a forwarder mirroring a peer’s STOP_SENDING must call this explicitly to keep the original code intact.

After a successful call the stream is no longer readable, and the two arms say so differently: the QUIC arm’s read returns TransportError::Read, the WebTransport arm’s returns TransportError::StreamClosed (the inner stream is consumed, because wtransport::RecvStream::stop takes self by value). Stop reading once you have stopped a stream rather than matching on which error comes back.

§Errors
  • TransportError::StreamClosed if the stream was already stopped, finished or reset.
  • TransportError::Write if code is outside the QUIC varint range (0..2^62) — Write because what failed is the STOP_SENDING frame this endpoint would have sent. Nothing is sent in that case and the stream stays readable.

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