Trait io::ByteReader

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

source

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

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§

source§

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

source§

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

source§

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

source§

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

Implementors§

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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