DataStream

Trait DataStream 

Source
pub trait DataStream: Send + Sync {
    // Required methods
    fn get_size(&mut self) -> Result<u64, ErrorTrace>;
    fn read(&mut self, buf: &mut [u8]) -> Result<usize, ErrorTrace>;
    fn seek(&mut self, pos: SeekFrom) -> Result<u64, ErrorTrace>;

    // Provided methods
    fn read_at_position(
        &mut self,
        buf: &mut [u8],
        pos: SeekFrom,
    ) -> Result<usize, ErrorTrace> { ... }
    fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), ErrorTrace> { ... }
    fn read_exact_at_position(
        &mut self,
        buf: &mut [u8],
        pos: SeekFrom,
    ) -> Result<u64, ErrorTrace> { ... }
}
Expand description

Data stream trait.

Required Methods§

Source

fn get_size(&mut self) -> Result<u64, ErrorTrace>

Retrieves the size of the data.

Source

fn read(&mut self, buf: &mut [u8]) -> Result<usize, ErrorTrace>

Reads data at the current position.

Source

fn seek(&mut self, pos: SeekFrom) -> Result<u64, ErrorTrace>

Sets the current position of the data.

Provided Methods§

Source

fn read_at_position( &mut self, buf: &mut [u8], pos: SeekFrom, ) -> Result<usize, ErrorTrace>

Reads data at a specific position.

Source

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), ErrorTrace>

Reads an exact amount of data at the current position.

Source

fn read_exact_at_position( &mut self, buf: &mut [u8], pos: SeekFrom, ) -> Result<u64, ErrorTrace>

Reads an exact amount of data at a specific position.

Implementations on Foreign Types§

Source§

impl DataStream for File

Source§

fn get_size(&mut self) -> Result<u64, ErrorTrace>

Retrieves the size of the data.

Source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize, ErrorTrace>

Reads data at the current position.

Source§

fn seek(&mut self, pos: SeekFrom) -> Result<u64, ErrorTrace>

Sets the current position of the data.

Implementors§