pub struct RandomAccessFile { /* private fields */ }
Expand description

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)?;

Implementations

Opens a file for random access.

Creates a RandomAccessFile wrapper around a File.

Tries to unwrap the inner File.

Trait Implementations

Formats the value using the given formatter. Read more

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

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

Writes bytes from a buffer to an offset, returning the number of bytes written. Read more

Flush this writer, ensuring that any intermediately buffered data reaches its destination. Read more

Writes a complete buffer at an offset. Read more

Writes bytes from a buffer to an offset, returning the number of bytes written. Read more

Flush this writer, ensuring that any intermediately buffered data reaches its destination. Read more

Writes a complete buffer at an offset. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.