Trait ChunkReader

Source
pub trait ChunkReader {
    type T: Read;

    // Required methods
    fn len(&self) -> u64;
    fn get_read(&self, offset_from_start: u64) -> Result<Self::T>;

    // Provided method
    fn get_bytes(&self, offset_from_start: u64, length: u64) -> Result<Bytes> { ... }
}
Expand description

Primary source used for reading required bytes for operations.

Required Associated Types§

Required Methods§

Source

fn len(&self) -> u64

Get total length of bytes. Useful for parsing the metadata located at the end of the file.

Source

fn get_read(&self, offset_from_start: u64) -> Result<Self::T>

Get a reader starting at a specific offset.

Provided Methods§

Source

fn get_bytes(&self, offset_from_start: u64, length: u64) -> Result<Bytes>

Read bytes from an offset with specific length.

Implementations on Foreign Types§

Source§

impl ChunkReader for File

Source§

fn get_read(&self, offset_from_start: u64) -> Result<Self::T>

Care needs to be taken when using this simultaneously as underlying file descriptor is the same and will be affected by other invocations.

See File::try_clone() for more details.

Source§

type T = BufReader<File>

Source§

fn len(&self) -> u64

Source§

impl ChunkReader for Bytes

Source§

type T = Reader<Bytes>

Source§

fn len(&self) -> u64

Source§

fn get_read(&self, offset_from_start: u64) -> Result<Self::T>

Implementors§