Skip to main content

AsyncWrite

Trait AsyncWrite 

Source
pub trait AsyncWrite {
    // Required methods
    async fn write<T: IoBuf>(&mut self, buf: T) -> BufResult<usize, T>;
    async fn flush(&mut self) -> Result<()>;
    async fn shutdown(&mut self) -> Result<()>;

    // Provided method
    async fn write_vectored<T: IoVectoredBuf>(
        &mut self,
        buf: T,
    ) -> BufResult<usize, T> { ... }
}
Expand description

§AsyncWrite

Async write with a ownership of a buffer

Required Methods§

Source

async fn write<T: IoBuf>(&mut self, buf: T) -> BufResult<usize, T>

Write some bytes from the buffer into this source and return a BufResult, consisting of the buffer and a usize indicating how many bytes were written.

Source

async fn flush(&mut self) -> Result<()>

Attempts to flush the object, ensuring that any buffered data reach their destination.

Source

async fn shutdown(&mut self) -> Result<()>

Initiates or attempts to shut down this writer, returning success when the I/O connection has completely shut down.

Provided Methods§

Source

async fn write_vectored<T: IoVectoredBuf>( &mut self, buf: T, ) -> BufResult<usize, T>

Like write, except that it write bytes from a buffer implements IoVectoredBuf into the source.

The default implementation will write from the first buffers with non-zero buf_len, meaning it’s possible and likely that not all contents are written. If guaranteed full write is desired, it is recommended to use AsyncWriteExt::write_vectored_all instead.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl AsyncWrite for &mut [u8]

Source§

async fn write<T: IoBuf>(&mut self, buf: T) -> BufResult<usize, T>

Source§

async fn write_vectored<T: IoVectoredBuf>( &mut self, buf: T, ) -> BufResult<usize, T>

Source§

async fn flush(&mut self) -> Result<()>

Source§

async fn shutdown(&mut self) -> Result<()>

Source§

impl AsyncWrite for Vec<u8>

Write is implemented for Vec<u8> by appending to the vector. The vector will grow as needed.

Source§

async fn write<T: IoBuf>(&mut self, buf: T) -> BufResult<usize, T>

Source§

async fn write_vectored<T: IoVectoredBuf>( &mut self, buf: T, ) -> BufResult<usize, T>

Source§

async fn flush(&mut self) -> Result<()>

Source§

async fn shutdown(&mut self) -> Result<()>

Source§

impl<A: AsyncWrite + ?Sized> AsyncWrite for &mut A

Source§

async fn write<T: IoBuf>(&mut self, buf: T) -> BufResult<usize, T>

Source§

async fn write_vectored<T: IoVectoredBuf>( &mut self, buf: T, ) -> BufResult<usize, T>

Source§

async fn flush(&mut self) -> Result<()>

Source§

async fn shutdown(&mut self) -> Result<()>

Source§

impl<A: AsyncWriteAt> AsyncWrite for Cursor<A>

Source§

async fn write<T: IoBuf>(&mut self, buf: T) -> BufResult<usize, T>

Source§

async fn write_vectored<T: IoVectoredBuf>( &mut self, buf: T, ) -> BufResult<usize, T>

Source§

async fn flush(&mut self) -> Result<()>

Source§

async fn shutdown(&mut self) -> Result<()>

Source§

impl<W: AsyncWrite + ?Sized> AsyncWrite for Box<W>

Source§

async fn write<T: IoBuf>(&mut self, buf: T) -> BufResult<usize, T>

Source§

async fn write_vectored<T: IoVectoredBuf>( &mut self, buf: T, ) -> BufResult<usize, T>

Source§

async fn flush(&mut self) -> Result<()>

Source§

async fn shutdown(&mut self) -> Result<()>

Implementors§