Trait io::ByteReader

source ·
pub trait ByteReader {
    fn read_at(
        &mut self,
        buffer: &mut [u8],
        offset: usize
    ) -> Result<usize, IoError>; }
Expand description

A trait that represents an I/O stream that can be read from at the granularity of individual bytes, but which does not track the current offset into the stream.

ByteReader implementation atop BlockReader

The ByteReader trait ideally should be auto-implemented for any type that implements the BlockReader trait, to allow easy byte-wise access to a block-based I/O stream. However, Rust does not allow trait specialization yet, so we cannot do this; instead, use the ByteReaderWrapper type to accomplish this.

Required Methods

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

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

Arguments
  • buffer: the buffer into which data will be copied.
  • offset: the offset in bytes from the beginning of this reader where the read operation will begin.
Return

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

Implementations on Foreign Types

Implementors