Struct quinn::RecvStream[][src]

pub struct RecvStream { /* fields omitted */ }

A stream that can only be used to receive data

stop(0) is implicitly called on drop unless:

  • ReadError::Finished has been emitted, or
  • stop was called explicitly

Implementations

impl RecvStream[src]

pub fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a>

Notable traits for Read<'a>

impl<'a> Future for Read<'a> type Output = Result<Option<usize>, ReadError>;
[src]

Read data contiguously from the stream.

Yields the number of bytes read into buf on success, or None if the stream was finished.

Applications involving bulk data transfer should consider using unordered reads for improved performance.

Panics

  • If used after read_unordered on the same stream. This is forbidden because an unordered read could consume a segment of data from a location other than the start of the receive buffer, making it impossible for future

pub fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a>

Notable traits for ReadExact<'a>

impl<'a> Future for ReadExact<'a> type Output = Result<(), ReadExactError>;
[src]

Read an exact number of bytes contiguously from the stream.

See read for details.

pub fn read_unordered(&mut self) -> ReadUnordered<'_>[src]

Read a segment of data from any offset in the stream.

Yields a segment of data and their offset in the stream, or None if the stream was finished. Segments may be received in any order and may overlap.

Unordered reads have reduced overhead and higher throughput, and should therefore be preferred when applicable.

pub fn read_to_end(self, size_limit: usize) -> ReadToEnd

Notable traits for ReadToEnd

impl Future for ReadToEnd type Output = Result<Vec<u8>, ReadToEndError>;
[src]

Convenience method to read all remaining data into a buffer

The returned future fails with ReadToEnd::TooLong if it’s longer than size_limit bytes. Uses unordered reads to be more efficient than using AsyncRead would allow. size_limit should be set to limit worst-case memory use.

If unordered reads have already been made, the resulting buffer may have gaps containing arbitrary data.

pub fn stop(&mut self, error_code: VarInt) -> Result<(), UnknownStream>[src]

Close the receive stream immediately.

The peer is notified and will cease transmitting on this stream, as if it had reset the stream itself. Further data may still be received on this stream if it was already in flight. Once called, a ReadError::Reset should be expected soon, although a peer might manage to finish the stream before it receives the reset, and a misbehaving peer might ignore the request entirely and continue sending until halted by flow control.

Has no effect if the incoming stream already finished, even if the local application hasn’t yet read all buffered data.

Trait Implementations

impl AsyncRead for RecvStream[src]

impl AsyncRead for RecvStream[src]

impl Debug for RecvStream[src]

impl Drop for RecvStream[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<R> AsyncReadExt for R where
    R: AsyncRead + ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,