Trait compio_io::AsyncReadAtExt
source · pub trait AsyncReadAtExt: AsyncReadAt {
// Provided methods
async fn read_exact_at<T: IoBufMut>(
&self,
buf: T,
pos: u64,
) -> BufResult<(), T> { ... }
async fn read_to_end_at(
&self,
buffer: Vec<u8>,
pos: u64,
) -> BufResult<usize, Vec<u8>> { ... }
async fn read_vectored_exact_at<T: IoVectoredBufMut>(
&self,
buf: T,
pos: u64,
) -> BufResult<(), T> { ... }
}
Expand description
Implemented as an extension trait, adding utility methods to all
AsyncReadAt
types. Callers will tend to import this trait instead of
AsyncReadAt
.
Provided Methods§
sourceasync fn read_exact_at<T: IoBufMut>(&self, buf: T, pos: u64) -> BufResult<(), T>
async fn read_exact_at<T: IoBufMut>(&self, buf: T, pos: u64) -> BufResult<(), T>
Read the exact number of bytes required to fill buffer
.
This function reads as many bytes as necessary to completely fill the
uninitialized space of specified buffer
.
§Errors
If this function encounters an “end of file” before completely filling
the buffer, it returns an error of the kind
ErrorKind::UnexpectedEof
. The contents of buffer
are unspecified
in this case.
If any other read error is encountered then this function immediately
returns. The contents of buffer
are unspecified in this case.
If this function returns an error, it is unspecified how many bytes it has read, but it will never read more than would be necessary to completely fill the buffer.
sourceasync fn read_to_end_at(
&self,
buffer: Vec<u8>,
pos: u64,
) -> BufResult<usize, Vec<u8>>
async fn read_to_end_at( &self, buffer: Vec<u8>, pos: u64, ) -> BufResult<usize, Vec<u8>>
Read all bytes until EOF in this source, placing them into buffer
.
All bytes read from this source will be appended to the specified buffer
buffer
. This function will continuously call read_at()
to append
more data to buffer
until read_at()
returns [Ok(0)
].
If successful, this function will return the total number of bytes read.
sourceasync fn read_vectored_exact_at<T: IoVectoredBufMut>(
&self,
buf: T,
pos: u64,
) -> BufResult<(), T>
async fn read_vectored_exact_at<T: IoVectoredBufMut>( &self, buf: T, pos: u64, ) -> BufResult<(), T>
Like AsyncReadExt::read_vectored_exact
, expect that it reads at a
specified position.