Trait io::BlockReader

source ·
pub trait BlockReader: BlockIo {
    fn read_blocks(
        &mut self,
        buffer: &mut [u8],
        block_offset: usize
    ) -> Result<usize, IoError>; }
Expand description

A trait that represents an I/O stream (e.g., an I/O device) that can be read from in blocks. The block size specifies the minimum granularity of each transfer, as given by the BlockIo::block_size() function.

A BlockReader is not aware of the current block offset into the stream; thus, each read operation requires a starting offset: the number of blocks from the beginning of the I/O stream at which the read should start.

Required Methods

Reads blocks of data from this reader into the given buffer.

The number of blocks read is dictated by the length of the given buffer.

Arguments
  • buffer: the buffer into which data will be read. The length of this buffer must be a multiple of the block size.
  • block_offset: the offset in number of blocks from the beginning of this reader.
Return

If successful, returns the number of blocks read into the given buffer. Otherwise, returns an error.

Implementations on Foreign Types

Implementors