Struct quinn::RecvStream [−][src]
A stream that can only be used to receive data
stop(0)
is implicitly called on drop unless:
ReadError::Finished
has been emitted, orstop
was called explicitly
Implementations
impl RecvStream
[src]
pub fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a>ⓘ
[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>ⓘ
[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ⓘ
[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]
fn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8]
) -> Poll<Result<usize>>
[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8]
) -> Poll<Result<usize>>
pub fn poll_read_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &mut [IoSliceMut<'_>]
) -> Poll<Result<usize, Error>>
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &mut [IoSliceMut<'_>]
) -> Poll<Result<usize, Error>>
impl AsyncRead for RecvStream
[src]
unsafe fn prepare_uninitialized_buffer(&self, _: &mut [MaybeUninit<u8>]) -> bool
[src]
fn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8]
) -> Poll<Result<usize>>
[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8]
) -> Poll<Result<usize>>
pub fn poll_read_buf<B>(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut B
) -> Poll<Result<usize, Error>> where
B: BufMut,
[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut B
) -> Poll<Result<usize, Error>> where
B: BufMut,
impl Debug for RecvStream
[src]
impl Drop for RecvStream
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<R> AsyncReadExt for R where
R: AsyncRead + ?Sized,
R: AsyncRead + ?Sized,
pub fn chain<R>(self, next: R) -> Chain<Self, R> where
R: AsyncRead,
R: AsyncRead,
pub fn read(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self> where
Self: Unpin,
Self: Unpin,
pub fn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectored<'a, Self> where
Self: Unpin,
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectored<'a, Self> where
Self: Unpin,
pub fn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> where
Self: Unpin,
Self: Unpin,
pub fn read_to_end(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEnd<'a, Self> where
Self: Unpin,
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEnd<'a, Self> where
Self: Unpin,
pub fn read_to_string(
&'a mut self,
buf: &'a mut String
) -> ReadToString<'a, Self> where
Self: Unpin,
&'a mut self,
buf: &'a mut String
) -> ReadToString<'a, Self> where
Self: Unpin,
pub fn split(self) -> (ReadHalf<Self>, WriteHalf<Self>) where
Self: AsyncWrite,
Self: AsyncWrite,
pub fn take(self, limit: u64) -> Take<Self>
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,