subspace_farmer_components::file_ext

Trait FileExt

source
pub trait FileExt {
    // Required methods
    fn size(&self) -> Result<u64>;
    fn preallocate(&self, len: u64) -> Result<()>;
    fn advise_random_access(&self) -> Result<()>;
    fn advise_sequential_access(&self) -> Result<()>;
    fn disable_cache(&self) -> Result<()>;
    fn read_exact_at(&self, buf: &mut [u8], offset: u64) -> Result<()>;
    fn write_all_at(&self, buf: &[u8], offset: u64) -> Result<()>;
}
Expand description

Extension convenience trait that allows pre-allocating files, suggesting random access pattern and doing cross-platform exact reads/writes

Required Methods§

source

fn size(&self) -> Result<u64>

Get file size

source

fn preallocate(&self, len: u64) -> Result<()>

Make sure file has specified number of bytes allocated for it

source

fn advise_random_access(&self) -> Result<()>

Advise OS/file system that file will use random access and read-ahead behavior is undesirable, on Windows this can only be set when file is opened, see OpenOptionsExt

source

fn advise_sequential_access(&self) -> Result<()>

Advise OS/file system that file will use sequential access and read-ahead behavior is desirable, on Windows this can only be set when file is opened, see OpenOptionsExt

source

fn disable_cache(&self) -> Result<()>

Disable cache on macOS

source

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

Read exact number of bytes at a specific offset

source

fn write_all_at(&self, buf: &[u8], offset: u64) -> Result<()>

Write all provided bytes at a specific offset

Implementations on Foreign Types§

source§

impl FileExt for File

source§

fn size(&self) -> Result<u64>

source§

fn preallocate(&self, len: u64) -> Result<()>

source§

fn advise_random_access(&self) -> Result<()>

source§

fn advise_sequential_access(&self) -> Result<()>

source§

fn disable_cache(&self) -> Result<()>

source§

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

source§

fn write_all_at(&self, buf: &[u8], offset: u64) -> Result<()>

Implementors§