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§
Provided Methods§
Sourceasync fn write_vectored<T: IoVectoredBuf>(
&mut self,
buf: T,
) -> BufResult<usize, T>
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 try to write from the buffers in order
as if they’re concatenated. It will stop whenever the writer returns
an error, Ok(0)
, or a length less than the length of the buf passed
in, meaning it’s possible 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", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl AsyncWrite for Vec<u8>
impl AsyncWrite for Vec<u8>
Write is implemented for Vec<u8>
by appending to the vector. The vector
will grow as needed.