Trait io::BlockReader

source ·
pub trait BlockReader: BlockIo {
    // Required method
    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§

source

fn read_blocks( &mut self, buffer: &mut [u8], block_offset: usize ) -> Result<usize, IoError>

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§

source§

impl<R> BlockReader for Box<R>where R: BlockReader + ?Sized,

source§

fn read_blocks( &mut self, buffer: &mut [u8], block_offset: usize ) -> Result<usize, IoError>

source§

impl<R> BlockReader for &mut Rwhere R: BlockReader + ?Sized,

source§

fn read_blocks( &mut self, buffer: &mut [u8], block_offset: usize ) -> Result<usize, IoError>

Implementors§

source§

impl<'io, IO, L, B> BlockReader for &LockableIo<'io, IO, L, B>where IO: BlockReader + 'io + ?Sized, L: for<'a> Lockable<'a, IO> + ?Sized, B: Borrow<L>,

source§

impl<'io, IO, L, B> BlockReader for LockableIo<'io, IO, L, B>where IO: BlockReader + 'io + ?Sized, L: for<'a> Lockable<'a, IO> + ?Sized, B: Borrow<L>,

source§

impl<IO> BlockReader for Reader<IO>where IO: BlockReader,

source§

impl<IO> BlockReader for ReaderWriter<IO>where IO: BlockReader,

source§

impl<R> BlockReader for ByteReaderWrapper<R>where R: BlockReader,

source§

impl<RW> BlockReader for ByteReaderWriterWrapper<RW>where RW: BlockReader + BlockWriter,