Skip to main content

RecvStream

Struct RecvStream 

Source
pub struct RecvStream { /* private fields */ }
Expand description

A byte stream received from the remote peer.

Either side may close with an error code, or the peer may close with a FIN.

Implementations§

Source§

impl RecvStream

Source

pub async fn read(&mut self, max: usize) -> Result<Option<Bytes>, Error>

Read the next chunk of data with the provided maximum size.

This returns a chunk of data instead of copying, which can be more efficient.

Source

pub async fn read_buf<B: BufMut>( &mut self, buf: &mut B, ) -> Result<Option<usize>, Error>

Read some data into the provided buffer.

Returns the (non-zero) number of bytes read, or None if the stream is closed. Advances the buffer by the number of bytes read.

Source

pub fn stop(&mut self, reason: &str)

Abort reading from the stream with the given reason.

Source

pub async fn closed(&self) -> Result<Option<u8>, Error>

Block until the stream has closed and return the error code, if any.

Trait Implementations§

Source§

impl AsyncRead for RecvStream

Source§

fn poll_read( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8], ) -> Poll<Result<usize>>

Attempt to read from the AsyncRead into buf. Read more
Source§

fn poll_read_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &mut [IoSliceMut<'_>], ) -> Poll<Result<usize, Error>>

Attempt to read from the AsyncRead into bufs using vectored IO operations. Read more
Source§

impl Drop for RecvStream

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl RecvStream for RecvStream

Available on target_family=wasm only.
Source§

type Error = Error

Error type returned by receive-side stream operations.
Source§

async fn read(&mut self, dst: &mut [u8]) -> Result<Option<usize>, Self::Error>

Read the next chunk of data, up to the max size. Read more
Source§

fn stop(&mut self, code: u32)

Send a STOP_SENDING QUIC code, informing the peer that no more data will be read. Read more
Source§

async fn closed(&mut self) -> Result<(), Self::Error>

Block until the stream has been closed by either side. Read more
Source§

fn read_buf<B>( &mut self, buf: &mut B, ) -> impl Future<Output = Result<Option<usize>, Self::Error>> + MaybeSend
where B: BufMut + MaybeSend,

Read some data into the provided buffer. Read more
Source§

fn read_chunk( &mut self, max: usize, ) -> impl Future<Output = Result<Option<Bytes>, Self::Error>> + MaybeSend

Read the next chunk of data, up to the max size. Read more
Source§

fn read_all( &mut self, ) -> impl Future<Output = Result<Bytes, Self::Error>> + MaybeSend

Helper to keep reading until the stream is closed.
Source§

fn read_all_buf<B>( &mut self, buf: &mut B, ) -> impl Future<Output = Result<usize, Self::Error>> + MaybeSend
where B: BufMut + MaybeSend,

Helper to keep reading until the buffer is full.

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.

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<T> MaybeSend for T

Source§

impl<T> MaybeSync for T