[][src]Struct positioned_io_preview::RandomAccessFile

pub struct RandomAccessFile { /* fields omitted */ }

A wrapper for File that provides optimized random access through ReadAt and WriteAt.

  • On Unix the operating system is advised that reads will be in random order (FADV_RANDOM).
  • On Windows the implementation is orders of magnitude faster than ReadAt directly on File.

Examples

Read the fifth 512-byte sector of a file:

use positioned_io::{RandomAccessFile, ReadAt};

// open a file (note: binding does not need to be mut)
let raf = RandomAccessFile::open("tests/pi.txt")?;

// read up to 512 bytes
let mut buf = [0; 512];
let bytes_read = raf.read_at(2048, &mut buf)?;

Methods

impl RandomAccessFile
[src]

Opens a file for random access.

Creates a RandomAccessFile wrapper around a File.

Tries to unwrap the inner File.

Trait Implementations

impl ReadAt for RandomAccessFile
[src]

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

impl WriteAt for RandomAccessFile
[src]

Writes a complete buffer at an offset. Read more

impl Debug for RandomAccessFile
[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]