pub trait AsyncRead {
// Required method
async fn read<B: IoBufMut>(&mut self, buf: B) -> BufResult<usize, B>;
// Provided method
async fn read_vectored<V: IoVectoredBufMut>(
&mut self,
buf: V,
) -> BufResult<usize, V> { ... }
}Expand description
AsyncRead
Async read with a ownership of a buffer
Required Methods§
Sourceasync fn read<B: IoBufMut>(&mut self, buf: B) -> BufResult<usize, B>
async fn read<B: IoBufMut>(&mut self, buf: B) -> BufResult<usize, B>
Read some bytes from this source into the IoBufMut buffer and return
a BufResult, consisting of the buffer and a usize indicating
how many bytes were read.
§Caution
- This function read data to the beginning of the buffer; that is,
all existing data in the buffer will be overwritten. To read data to
the end of the buffer, use
AsyncReadExt::append. - Implementor MUST update the buffer init via
SetLen::set_lenafter reading, and no further update should be made by caller.
Provided Methods§
Sourceasync fn read_vectored<V: IoVectoredBufMut>(
&mut self,
buf: V,
) -> BufResult<usize, V>
async fn read_vectored<V: IoVectoredBufMut>( &mut self, buf: V, ) -> BufResult<usize, V>
Like read, except that it reads into a type implements
IoVectoredBufMut.
The default implementation will read only to first buffer in buf with
non-zero capacity and return, meaning it’s possible and likely that not
all buffer space is filled. If guaranteed full read is desired,
it is recommended to use AsyncReadExt::read_vectored_exact instead.
§Caution
Implementor MUST update the buffer init via
SetLen::set_len after reading.
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.