pub trait AsyncSliceReader {
// Required methods
fn read_at(
&mut self,
offset: u64,
len: usize,
) -> impl Future<Output = Result<Bytes, Error>>;
fn size(&mut self) -> impl Future<Output = Result<u64, Error>>;
// Provided method
fn read_exact_at(
&mut self,
offset: u64,
len: usize,
) -> impl Future<Output = Result<Bytes, Error>> { ... }
}
Expand description
A trait to abstract async reading from different resource.
This trait does not require the notion of a current position, but instead requires explicitly passing the offset to read_at. In addition to the ability to read at an arbitrary offset, it also provides the ability to get the length of the resource.
This is similar to the io interface of sqlite. See xRead, xFileSize in https://www.sqlite.org/c3ref/io_methods.html
Required Methods§
Sourcefn read_at(
&mut self,
offset: u64,
len: usize,
) -> impl Future<Output = Result<Bytes, Error>>
fn read_at( &mut self, offset: u64, len: usize, ) -> impl Future<Output = Result<Bytes, Error>>
Read the entire buffer at the given position.
Will return at most len
bytes, but may return fewer if the resource is smaller.
If the range is completely covered by the resource, will return exactly len
bytes.
If the range is not covered at all by the resource, will return an empty buffer.
It will never return an io error independent of the range as long as the underlying
resource is valid.
Provided Methods§
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.