Trait bao_tree::io::sync::SliceReader

source ·
pub trait SliceReader {
    // Required methods
    fn read_at(&mut self, offset: u64, buf: &mut [u8]) -> Result<()>;
    fn len(&mut self) -> Result<u64>;
}
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.

This is similar to the io interface of sqlite. See xRead, xFileSize in https://www.sqlite.org/c3ref/io_methods.html

Required Methods§

source

fn read_at(&mut self, offset: u64, buf: &mut [u8]) -> Result<()>

source

fn len(&mut self) -> Result<u64>

Implementors§

source§

impl<R: Read + Seek> SliceReader for R