Struct s2n_quic_transport::stream::ReceiveStream
source · pub struct ReceiveStream(/* private fields */);
Expand description
A readable QUIC stream
Implementations§
source§impl ReceiveStream
impl ReceiveStream
pub fn id(&self) -> StreamId
pub fn connection(&self) -> &Connection
pub fn rx_request(&mut self) -> Result<RxRequest<'_, '_>, StreamError>
sourcepub fn poll_receive(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<Option<Bytes>, StreamError>>
pub fn poll_receive( &mut self, cx: &mut Context<'_> ) -> Poll<Result<Option<Bytes>, StreamError>>
Receives a chunk of data from the stream.
The method will return:
Poll::Ready(Ok(Some(chunk)))
if the stream is open and data was availablePoll::Ready(Ok(None))
if the stream was finished and all of the data was consumedPoll::Ready(Err(stream_error))
if the stream could not be read, because the stream had previously entered an error state.Poll::Pending
if the stream is waiting to receive data from the peer. In this case, the caller should retry sending after theWaker
on the providedContext
is notified.
sourcepub fn poll_receive_vectored(
&mut self,
chunks: &mut [Bytes],
cx: &mut Context<'_>
) -> Poll<Result<(usize, bool), StreamError>>
pub fn poll_receive_vectored( &mut self, chunks: &mut [Bytes], cx: &mut Context<'_> ) -> Poll<Result<(usize, bool), StreamError>>
Receives a slice of chunks of data from the stream.
The method will return:
Poll::Ready(Ok((len, is_open)))
if the stream received data into the slice, wherelen
was the number of chunks received, andis_open
indicating if the stream is still open. Ifis_open == false
, future calls topoll_receive_vectored
will always returnPoll::Ready(Ok((0, false)))
.Poll::Ready(Err(stream_error))
if the stream could not be read, because the stream had previously entered an error state.Poll::Pending
if the stream is waiting to receive data from the peer. In this case, the caller should retry sending after theWaker
on the providedContext
is notified.
sourcepub fn stop_sending(&mut self, error_code: Error) -> Result<(), StreamError>
pub fn stop_sending(&mut self, error_code: Error) -> Result<(), StreamError>
Sends a STOP_SENDING
message to the peer. This requests the peer to
finish the Stream
as soon as possible by issuing a RESET
with the
provided error_code
.
Since this is merely a request to the peer to RESET
the Stream
, the
Stream
will not immediately be in a RESET
state after issuing this
API call.
If the Stream
had been previously reset by the peer or if all data had
already been received the API call will not trigger any action.
Trait Implementations§
source§impl Debug for ReceiveStream
impl Debug for ReceiveStream
Auto Trait Implementations§
impl Freeze for ReceiveStream
impl !RefUnwindSafe for ReceiveStream
impl Send for ReceiveStream
impl Sync for ReceiveStream
impl Unpin for ReceiveStream
impl !UnwindSafe for ReceiveStream
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more