Struct s2n_quic_transport::stream::Stream
source · [−]pub struct Stream(_);
Expand description
A readable and writeable QUIC stream
Implementations
sourceimpl Stream
impl Stream
pub fn id(&self) -> StreamId
pub fn connection(&self) -> &Connection
pub fn request(&mut self) -> Request<'_, '_>ⓘNotable traits for Request<'state, 'chunks>impl<'state, 'chunks> Future for Request<'state, 'chunks> type Output = Result<Response, StreamError>;
pub fn tx_request(&mut self) -> Result<TxRequest<'_, '_>, StreamError>
pub fn rx_request(&mut self) -> Result<RxRequest<'_, '_>, StreamError>
sourcepub fn poll_send(
&mut self,
chunk: &mut Bytes,
cx: &mut Context<'_>
) -> Poll<Result<(), StreamError>>
pub fn poll_send(
&mut self,
chunk: &mut Bytes,
cx: &mut Context<'_>
) -> Poll<Result<(), StreamError>>
Enqueues a chunk of data for sending it towards the peer.
The method will return:
Poll::Ready(Ok(()))
if the data was enqueued for sending. The providedBytes
will be replaced with an emptyBytes
, in order to reduce needless ref count increases.Poll::Ready(Err(stream_error))
if the data could not be sent, because the stream had previously entered an error state.Poll::Pending
if the send buffer capacity is currently exhausted. In this case, the caller should retry sending after theWaker
on the providedContext
is notified.
sourcepub fn poll_send_vectored(
&mut self,
chunks: &mut [Bytes],
cx: &mut Context<'_>
) -> Poll<Result<usize, StreamError>>
pub fn poll_send_vectored(
&mut self,
chunks: &mut [Bytes],
cx: &mut Context<'_>
) -> Poll<Result<usize, StreamError>>
Enqueues a slice of chunks of data for sending it towards the peer.
The method will return:
Poll::Ready(Ok(count))
if part of the slice was enqueued for sending. Any of the consumedBytes
will be replaced with an emptyBytes
, in order to reduce needless ref count increases. Ifcount
does not equal the total number of chunks, the stream will store the waker and wake the task once more capacity is available.Poll::Ready(Err(stream_error))
if the data could not be sent, because the stream had previously entered an error state.Poll::Pending
if the send buffer capacity is currently exhausted. In this case, the caller should retry sending after theWaker
on the providedContext
is notified.
sourcepub fn poll_send_ready(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<usize, StreamError>>
pub fn poll_send_ready(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<usize, StreamError>>
Polls send readiness for the given stream.
The method will return:
Poll::Ready(Ok(available_bytes))
if the stream is ready to send data, whereavailable_bytes
is how many bytes the stream can currently accept.Poll::Ready(Err(stream_error))
if the data could not be sent, because the stream had previously entered an error state.Poll::Pending
if the send buffer capacity is currently exhausted. In this case, the caller should retry sending after theWaker
on the providedContext
is notified.
sourcepub fn send_data(&mut self, chunk: Bytes) -> Result<(), StreamError>
pub fn send_data(&mut self, chunk: Bytes) -> Result<(), StreamError>
Enqueues a chunk of data for sending it towards the peer.
This method should only be called after calling poll_send_ready
first, as the stream
may not have available send buffer capacity.
The method will return:
Ok(())
if the data was enqueued for sending.Err(stream_error)
if the data could not be sent, because the stream had previously entered an error state, or the stream was not ready to send data.
sourcepub fn poll_flush(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<(), StreamError>>
pub fn poll_flush(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<(), StreamError>>
Flushes the send buffer and waits for acknowledgement from the peer.
The method will return:
Poll::Ready(Ok(()))
if the send buffer was completely flushed and acknowledged.Poll::Ready(Err(stream_error))
if the stream could not be flushed, because the stream had previously entered an error state.Poll::Pending
if the send buffer is still being flushed. In this case, the caller should retry sending after theWaker
on the providedContext
is notified.
sourcepub fn finish(&mut self) -> Result<(), StreamError>
pub fn finish(&mut self) -> Result<(), StreamError>
Marks the stream as finished.
The method will return:
Ok(())
if the stream was finished successfullyErr(stream_error)
if the stream could not be finished, because the stream had previously entered an error state.
sourcepub fn poll_close(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<(), StreamError>>
pub fn poll_close(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<(), StreamError>>
Marks the stream as finished and waits for all outstanding data to be acknowledged
The method will return:
Poll::Ready(Ok(()))
if the stream was completely flushed and acknowledged.Poll::Ready(Err(stream_error))
if the stream could not be flushed, because the stream had previously entered an error state.Poll::Pending
if the stream is still being flushed. In this case, the caller should retry sending after theWaker
on the providedContext
is notified.
sourcepub fn reset(&mut self, error_code: Error) -> Result<(), StreamError>
pub fn reset(&mut self, error_code: Error) -> Result<(), StreamError>
Initiates a RESET
on the stream.
This will close the stream and notify the peer of the provided error_code
.
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.
sourcepub fn split(self) -> (ReceiveStream, SendStream)
pub fn split(self) -> (ReceiveStream, SendStream)
Splits a bidirectional QUIC Stream in two halves.
One half can be used to read data from the Stream. The other half can be used to send data.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Stream
impl Send for Stream
impl Sync for Stream
impl Unpin for Stream
impl !UnwindSafe for Stream
Blanket Implementations
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