Trait bao_tree::io::fsm::AsyncSliceReader
source · pub trait AsyncSliceReader: Sized {
type ReadFuture: Future<Output = (Self, BytesMut, Result<()>)> + Send;
type LenFuture: Future<Output = (Self, Result<u64>)> + Send;
// Required methods
fn read_at(self, offset: u64, buf: BytesMut) -> Self::ReadFuture;
fn len(self) -> Self::LenFuture;
}Expand description
A reader that can read a slice at a specified offset
For a file, this will be implemented by seeking to the offset and then reading the data. For other types of storage, seeking is not necessary. E.g. a Bytes or a memory mapped slice already allows random access.
For external storage such as S3/R2, this might be implemented in terms of async http requests.
This is similar to the io interface of sqlite. See xRead, xFileSize in https://www.sqlite.org/c3ref/io_methods.html
Required Associated Types§
type ReadFuture: Future<Output = (Self, BytesMut, Result<()>)> + Send
type LenFuture: Future<Output = (Self, Result<u64>)> + Send
Required Methods§
sourcefn read_at(self, offset: u64, buf: BytesMut) -> Self::ReadFuture
fn read_at(self, offset: u64, buf: BytesMut) -> Self::ReadFuture
Read the entire buffer at the given position.
Will fail if the file is smaller than offset + buf.len()