pub trait RecvStream: MaybeSend {
type Error: Error;
// Required methods
fn read(
&mut self,
dst: &mut [u8],
) -> impl Future<Output = Result<Option<usize>, Self::Error>> + MaybeSend;
fn stop(&mut self, code: u32);
fn closed(
&mut self,
) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend;
// Provided methods
fn read_buf<B: BufMut + MaybeSend>(
&mut self,
buf: &mut B,
) -> impl Future<Output = Result<Option<usize>, Self::Error>> + MaybeSend { ... }
fn read_chunk(
&mut self,
max: usize,
) -> impl Future<Output = Result<Option<Bytes>, Self::Error>> + MaybeSend { ... }
fn read_all(
&mut self,
) -> impl Future<Output = Result<Bytes, Self::Error>> + MaybeSend { ... }
fn read_all_buf<B: BufMut + MaybeSend>(
&mut self,
buf: &mut B,
) -> impl Future<Output = Result<usize, Self::Error>> + MaybeSend { ... }
}Expand description
An incoming stream of bytes from the peer.
All bytes are flushed in order and the stream is flow controlled. The stream is closed with STOP_SENDING code=0 when dropped.
Required Associated Types§
Required Methods§
Sourcefn read(
&mut self,
dst: &mut [u8],
) -> impl Future<Output = Result<Option<usize>, Self::Error>> + MaybeSend
fn read( &mut self, dst: &mut [u8], ) -> impl Future<Output = Result<Option<usize>, Self::Error>> + MaybeSend
Read the next chunk of data, up to the max size.
This returns a chunk of data instead of copying, which can be more efficient.
Sourcefn stop(&mut self, code: u32)
fn stop(&mut self, code: u32)
Send a STOP_SENDING QUIC code, informing the peer that no more data will be read.
Implementations must do this on drop to avoid leaking flow control. Call this method manually to specify a custom code.
Sourcefn closed(
&mut self,
) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend
fn closed( &mut self, ) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend
Block until the stream has been closed by either side.
This includes:
- We received a RESET_STREAM via SendStream::reset
- We sent a STOP_SENDING via RecvStream::stop
- We received a FIN via SendStream::finish and read all data.
Provided Methods§
Sourcefn read_buf<B: BufMut + MaybeSend>(
&mut self,
buf: &mut B,
) -> impl Future<Output = Result<Option<usize>, Self::Error>> + MaybeSend
fn read_buf<B: BufMut + MaybeSend>( &mut self, buf: &mut B, ) -> impl Future<Output = Result<Option<usize>, Self::Error>> + MaybeSend
Read some data into the provided buffer.
The number of bytes read is returned, or None if the stream is closed.
The buffer is advanced by the number of bytes read.
Sourcefn read_chunk(
&mut self,
max: usize,
) -> impl Future<Output = Result<Option<Bytes>, Self::Error>> + MaybeSend
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.
This returns a chunk of data instead of copying, which can be more efficient.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".