Skip to main content

SendStream

Struct SendStream 

Source
pub struct SendStream { /* private fields */ }
Expand description

A byte stream sent to the remote peer.

Implementations§

Source§

impl SendStream

Source

pub async fn write(&mut self, buf: &[u8]) -> Result<(), Error>

Write all of the provided bytes to the stream.

Source

pub async fn write_buf<B: Buf>(&mut self, buf: &mut B) -> Result<usize, Error>

Write some of the provided buffer to the stream.

Source

pub fn reset(&mut self, reason: &str)

Send an immediate reset, closing the stream with an error.

Source

pub fn finish(&mut self) -> Result<(), Error>

Mark the stream as finished.

This is called on drop, but can also be invoked manually.

Source

pub fn set_priority(&mut self, priority: i32) -> Result<(), Error>

Set the stream’s priority.

Streams with higher values are sent first, but delivery order is not guaranteed.

Source

pub async fn closed(&self) -> Result<Option<u8>, Error>

Block until the stream has closed and return the error code, if any.

Trait Implementations§

Source§

impl AsyncWrite for SendStream

Source§

fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize>>

Attempt to write bytes from buf into the object. Read more
Source§

fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>

Attempt to flush the object, ensuring that any buffered data reach their destination. Read more
Source§

fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>

Attempt to close the object. Read more
Source§

fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>

Attempt to write bytes from bufs into the object using vectored IO operations. Read more
Source§

impl Drop for SendStream

Source§

fn drop(&mut self)

Close the stream with a FIN.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl SendStream for SendStream

Available on target_family=wasm only.
Source§

type Error = Error

Error type returned by send-side stream operations.
Source§

async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>

Write some of the buffer to the stream. Read more
Source§

fn set_priority(&mut self, order: u8)

Set the stream’s priority. Read more
Source§

fn finish(&mut self) -> Result<(), Self::Error>

Mark the stream as finished, erroring on any future writes. Read more
Source§

fn reset(&mut self, code: u32)

Immediately close the stream and discard any remaining data. Read more
Source§

async fn closed(&mut self) -> Result<(), Self::Error>

Block until the stream is closed by either side. Read more
Source§

fn write_buf<B>( &mut self, buf: &mut B, ) -> impl Future<Output = Result<usize, Self::Error>> + MaybeSend
where B: Buf + MaybeSend,

Write the given buffer to the stream, advancing the internal position.
Source§

fn write_chunk( &mut self, chunk: Bytes, ) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend

Write the entire Bytes chunk to the stream, potentially avoiding a copy.
Source§

fn write_all( &mut self, buf: &[u8], ) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend

Helper to write all data in the buffer.
Source§

fn write_all_buf<B>( &mut self, buf: &mut B, ) -> impl Future<Output = Result<(), Self::Error>> + MaybeSend
where B: Buf + MaybeSend,

Helper to write all data in the buffer.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<W> AsyncWriteExt for W
where W: AsyncWrite + ?Sized,

Source§

fn flush(&mut self) -> Flush<'_, Self>
where Self: Unpin,

Creates a future which will entirely flush this AsyncWrite. Read more
Source§

fn close(&mut self) -> Close<'_, Self>
where Self: Unpin,

Creates a future which will entirely close this AsyncWrite.
Source§

fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self>
where Self: Unpin,

Creates a future which will write bytes from buf into the object. Read more
Source§

fn write_vectored<'a>( &'a mut self, bufs: &'a [IoSlice<'a>], ) -> WriteVectored<'a, Self>
where Self: Unpin,

Creates a future which will write bytes from bufs into the object using vectored IO operations. Read more
Source§

fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAll<'a, Self>
where Self: Unpin,

Write data into this object. Read more
Source§

fn into_sink<Item>(self) -> IntoSink<Self, Item>
where Item: AsRef<[u8]>, Self: Sized,

Allow using an AsyncWrite as a Sink<Item: AsRef<[u8]>>. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSend for T

Source§

impl<T> MaybeSync for T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more