[][src]Trait rc_zip::prelude::ReadAt

pub trait ReadAt {
    fn read_at(&self, pos: u64, buf: &mut [u8]) -> Result<usize, Error>;

    fn read_exact_at(&self, pos: u64, buf: &mut [u8]) -> Result<(), Error> { ... }
}

Trait for reading at an offset.

Implementations should be able to read bytes without changing any sort of read-position. Self should not change at all. Buffering reads is unlikely to be useful, since each time read_at() is called, the position may be completely different.

Examples

Read the fifth 512-byte sector of a file:

use positioned_io::ReadAt;

let file = try!(File::open("foo.data"));
let mut buf = vec![0; 512];
let bytes_read = try!(file.read_at(2048, &mut buf));

Required methods

fn read_at(&self, pos: u64, buf: &mut [u8]) -> Result<usize, Error>

Read bytes from an offset in this source into a buffer, returning how many bytes were read.

This function may yield fewer bytes than the size of buf, if it was interrupted or hit end-of-file.

See Read::read().

Loading content...

Provided methods

fn read_exact_at(&self, pos: u64, buf: &mut [u8]) -> Result<(), Error>

Read the exact number of bytes required to fill buf, from an offset.

If only a lesser number of bytes can be read, will yield an error.

Loading content...

Trait Implementations

impl ReadZipWithSize for dyn ReadAt[src]

Implementations on Foreign Types

impl<I, E> ReadAt for ByteIo<I, E> where
    E: ByteOrder,
    I: ReadAt
[src]

impl ReadAt for File[src]

impl<'a, R> ReadAt for &'a RefCell<R> where
    R: ReadAt
[src]

impl<'a> ReadAt for &'a [u8][src]

impl<'a, R> ReadAt for &'a R where
    R: ReadAt + ?Sized
[src]

impl<'a> ReadAt for &'a mut [u8][src]

impl<'a, R> ReadAt for &'a mut R where
    R: ReadAt + ?Sized
[src]

impl ReadAt for Vec<u8>[src]

impl<I> ReadAt for Slice<I> where
    I: ReadAt
[src]

Loading content...

Implementors

Loading content...