pub trait Read: MaybeSend + MaybeSync {
type Error: Error + Send + Sync + 'static;
// Required methods
fn read_exact_at<B: IoBufMut>(
&mut self,
buf: B,
pos: u64,
) -> impl Future<Output = (Result<(), Self::Error>, B)> + MaybeSend;
fn read_to_end_at(
&mut self,
buf: Vec<u8>,
pos: u64,
) -> impl Future<Output = (Result<(), Self::Error>, Vec<u8>)> + MaybeSend;
fn size(&self) -> impl Future<Output = Result<u64, Self::Error>> + MaybeSend;
}Expand description
The core trait for reading data,
it is similar to [std::io::Read],
but it takes the ownership of the buffer,
because completion-based IO requires the buffer to be pinned and should be safe to
cancellation.
Read represents “random exactly read” semantics,
which means the read operation will start at the specified position, and the buffer will be
exactly filled with the data read.
The buffer will be returned with the result, whether the operation is successful or not, fusio promises that the returned buffer will be the same as the input buffer.
If you want sequential reading, try [SeqRead].
§Dyn Compatibility
This trait is not dyn compatible.
If you want to use Read trait in a dynamic way, you could use DynRead trait.
Required Associated Types§
Required Methods§
fn read_exact_at<B: IoBufMut>( &mut self, buf: B, pos: u64, ) -> impl Future<Output = (Result<(), Self::Error>, B)> + MaybeSend
fn read_to_end_at( &mut self, buf: Vec<u8>, pos: u64, ) -> impl Future<Output = (Result<(), Self::Error>, Vec<u8>)> + MaybeSend
fn size(&self) -> impl Future<Output = Result<u64, Self::Error>> + MaybeSend
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.