Struct quinn::RecvStream
source · [−]pub struct RecvStream { /* private fields */ }
Expand description
Implementations
sourceimpl RecvStream
impl RecvStream
sourcepub 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>;
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>;
Read data contiguously from the stream.
Yields the number of bytes read into buf
on success, or None
if the stream was finished.
sourcepub 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>;
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>;
Read an exact number of bytes contiguously from the stream.
See read()
for details.
sourcepub fn read_chunk(&mut self, max_length: usize, ordered: bool) -> ReadChunk<'_>ⓘNotable traits for ReadChunk<'a>impl<'a> Future for ReadChunk<'a> type Output = Result<Option<Chunk>, ReadError>;
pub fn read_chunk(&mut self, max_length: usize, ordered: bool) -> ReadChunk<'_>ⓘNotable traits for ReadChunk<'a>impl<'a> Future for ReadChunk<'a> type Output = Result<Option<Chunk>, ReadError>;
Read the next segment of data
Yields None
if the stream was finished. Otherwise, yields a segment of data and its
offset in the stream. If ordered
is true
, the chunk’s offset will be immediately after
the last data yielded by read()
or read_chunk()
. If ordered
is false
, segments may
be received in any order, and the Chunk
’s offset
field can be used to determine
ordering in the caller. Unordered reads are less prone to head-of-line blocking within a
stream, but require the application to manage reassembling the original data.
Slightly more efficient than read
due to not copying. Chunk boundaries do not correspond
to peer writes, and hence cannot be used as framing.
sourcepub fn read_chunks<'a>(&'a mut self, bufs: &'a mut [Bytes]) -> ReadChunks<'a>ⓘNotable traits for ReadChunks<'a>impl<'a> Future for ReadChunks<'a> type Output = Result<Option<usize>, ReadError>;
pub fn read_chunks<'a>(&'a mut self, bufs: &'a mut [Bytes]) -> ReadChunks<'a>ⓘNotable traits for ReadChunks<'a>impl<'a> Future for ReadChunks<'a> type Output = Result<Option<usize>, ReadError>;
Read the next segments of data
Fills bufs
with the segments of data beginning immediately after the
last data yielded by read
or read_chunk
, or None
if the stream was
finished.
Slightly more efficient than read
due to not copying. Chunk boundaries
do not correspond to peer writes, and hence cannot be used as framing.
sourcepub fn read_to_end(self, size_limit: usize) -> ReadToEndⓘNotable traits for ReadToEndimpl Future for ReadToEnd type Output = Result<Vec<u8>, ReadToEndError>;
pub fn read_to_end(self, size_limit: usize) -> ReadToEndⓘNotable traits for ReadToEndimpl Future for ReadToEnd type Output = Result<Vec<u8>, ReadToEndError>;
Convenience method to read all remaining data into a buffer
The returned future fails with ReadToEndError::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.
sourcepub fn stop(&mut self, error_code: VarInt) -> Result<(), UnknownStream>
pub fn stop(&mut self, error_code: VarInt) -> Result<(), UnknownStream>
Stop accepting data
Discards unread data and notifies the peer to stop transmitting. Once stopped, further
attempts to operate on a stream will yield UnknownStream
errors.
Trait Implementations
sourceimpl AsyncRead for RecvStream
impl AsyncRead for RecvStream
sourcefn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8]
) -> Poll<Result<usize>>
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
fn poll_read_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &mut [IoSliceMut<'_>]
) -> Poll<Result<usize, Error>>
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
sourceimpl AsyncRead for RecvStream
impl AsyncRead for RecvStream
sourceimpl Debug for RecvStream
impl Debug for RecvStream
Auto Trait Implementations
impl RefUnwindSafe for RecvStream
impl Send for RecvStream
impl Sync for RecvStream
impl Unpin for RecvStream
impl UnwindSafe for RecvStream
Blanket Implementations
sourceimpl<R> AsyncReadExt for R where
R: AsyncRead + ?Sized,
impl<R> AsyncReadExt for R where
R: AsyncRead + ?Sized,
sourcefn chain<R>(self, next: R) -> Chain<Self, R> where
R: AsyncRead,
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: AsyncRead,
Creates an adaptor which will chain this stream with another. Read more
sourcefn read(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self> where
Self: Unpin,
fn read(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self> where
Self: Unpin,
Tries to read some bytes directly into the given buf
in asynchronous
manner, returning a future type. Read more
sourcefn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectored<'a, Self> where
Self: Unpin,
fn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectored<'a, Self> where
Self: Unpin,
Creates a future which will read from the AsyncRead
into bufs
using vectored
IO operations. Read more
sourcefn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> where
Self: Unpin,
fn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> where
Self: Unpin,
Creates a future which will read exactly enough bytes to fill buf
,
returning an error if end of file (EOF) is hit sooner. Read more
sourcefn read_to_end(&'a mut self, buf: &'a mut Vec<u8, Global>) -> ReadToEnd<'a, Self> where
Self: Unpin,
fn read_to_end(&'a mut self, buf: &'a mut Vec<u8, Global>) -> ReadToEnd<'a, Self> where
Self: Unpin,
Creates a future which will read all the bytes from this AsyncRead
. Read more
sourcefn read_to_string(&'a mut self, buf: &'a mut String) -> ReadToString<'a, Self> where
Self: Unpin,
fn read_to_string(&'a mut self, buf: &'a mut String) -> ReadToString<'a, Self> where
Self: Unpin,
Creates a future which will read all the bytes from this AsyncRead
. Read more
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more