Struct wtransport::stream::SendStream
source · pub struct SendStream(/* private fields */);
Expand description
A stream that can only be used to send data.
Implementations§
source§impl SendStream
impl SendStream
sourcepub async fn write(&mut self, buf: &[u8]) -> Result<usize, StreamWriteError>
pub async fn write(&mut self, buf: &[u8]) -> Result<usize, StreamWriteError>
Writes bytes to the stream.
On success, returns the number of bytes written.
Congestion and flow control may cause this to be shorter than buf.len()
,
indicating that only a prefix of buf
was written.
sourcepub async fn write_all(&mut self, buf: &[u8]) -> Result<(), StreamWriteError>
pub async fn write_all(&mut self, buf: &[u8]) -> Result<(), StreamWriteError>
Convenience method to write an entire buffer to the stream.
sourcepub async fn finish(&mut self) -> Result<(), StreamWriteError>
pub async fn finish(&mut self) -> Result<(), StreamWriteError>
Shut down the stream gracefully.
No new data may be written after calling this method. Completes when the peer has acknowledged all sent data, retransmitting data as needed.
sourcepub fn set_priority(&self, priority: i32)
pub fn set_priority(&self, priority: i32)
Sets the priority of the send stream.
Every send stream has an initial priority of 0. Locally buffered data from streams with higher priority will be transmitted before data from streams with lower priority. Changing the priority of a stream with pending data may only take effect after that data has been transmitted. Using many different priority levels per connection may have a negative impact on performance.
sourcepub fn reset(self, error_code: VarInt)
pub fn reset(self, error_code: VarInt)
Closes the send stream immediately.
No new data can be written after calling this method. Locally buffered data is dropped, and previously transmitted data will no longer be retransmitted if lost. If an attempt has already been made to finish the stream, the peer may still receive all written data.
sourcepub async fn stopped(self) -> StreamWriteError
pub async fn stopped(self) -> StreamWriteError
Awaits for the stream to be stopped by the peer.
If the stream is stopped the error code will be stored in StreamWriteError::Stopped
.
sourcepub fn quic_stream(&self) -> &SendStream
Available on crate feature quinn
only.
pub fn quic_stream(&self) -> &SendStream
quinn
only.Returns a reference to the underlying QUIC stream.
sourcepub fn quic_stream_mut(&mut self) -> &mut SendStream
Available on crate feature quinn
only.
pub fn quic_stream_mut(&mut self) -> &mut SendStream
quinn
only.Returns a mutable reference to the underlying QUIC stream.
Trait Implementations§
source§impl AsyncWrite for SendStream
impl AsyncWrite for SendStream
source§fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize>>
buf
into the object. Read moresource§fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
source§fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
source§fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>]
) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize, Error>>
poll_write
, except that it writes from a slice of buffers. Read moresource§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
poll_write_vectored
implementation. Read more