Struct quinn::generic::RecvStream [−][src]
A stream that can only be used to receive data
stop(0)
is implicitly called on drop unless:
- A variant of
ReadError
has been emitted byread()
,read_exact()
orread_unordered()
stop()
was called explicitly
Implementations
impl<S> RecvStream<S> where
S: Session,
[src]
S: Session,
pub fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, S>ⓘ
[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, S>ⓘ
[src]
Read an exact number of bytes contiguously from the stream.
See read()
for details.
pub fn read_chunk(
&mut self,
max_length: usize,
ordered: bool
) -> ReadChunk<'_, S>ⓘ
[src]
&mut self,
max_length: usize,
ordered: bool
) -> ReadChunk<'_, S>ⓘ
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 have reduced overhead and higher throughput, and
should therefore be preferred when applicable.
Slightly more efficient than read
due to not copying. Chunk boundaries do not correspond
to peer writes, and hence cannot be used as framing.
pub fn read_chunks<'a>(&'a mut self, bufs: &'a mut [Bytes]) -> ReadChunks<'a, S>ⓘNotable traits for ReadChunks<'a, S>
impl<'a, S> Future for ReadChunks<'a, S> where
S: Session, type Output = Result<Option<usize>, ReadError>;
[src]
Notable traits for ReadChunks<'a, S>
impl<'a, S> Future for ReadChunks<'a, S> where
S: Session, 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.
pub fn read_to_end(self, size_limit: usize) -> ReadToEnd<S>ⓘ
[src]
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.
pub fn stop(&mut self, error_code: VarInt) -> Result<(), UnknownStream>
[src]
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.
pub fn is_0rtt(&self) -> bool
[src]
Check if this stream has been opened during 0-RTT.
In which case any non-idempotent request should be considered dangerous at the application level. Because read data is subject to replay attacks.
pub fn id(&self) -> StreamId
[src]
Get the identity of this stream
Trait Implementations
impl<S> AsyncRead for RecvStream<S> where
S: Session,
[src]
S: Session,
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<S> AsyncRead for RecvStream<S> where
S: Session,
[src]
S: Session,
fn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut ReadBuf<'_>
) -> Poll<Result<()>>
[src]
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut ReadBuf<'_>
) -> Poll<Result<()>>
impl<S: Debug> Debug for RecvStream<S> where
S: Session,
[src]
S: Session,
impl<S> Drop for RecvStream<S> where
S: Session,
[src]
S: Session,
Auto Trait Implementations
impl<S> RefUnwindSafe for RecvStream<S>
impl<S> Send for RecvStream<S>
impl<S> Sync for RecvStream<S>
impl<S> Unpin for RecvStream<S>
impl<S> UnwindSafe for RecvStream<S>
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>,