pub trait FileExt { fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>; fn write_at(&self, buf: &[u8], offset: u64) -> Result<usize>; }
Unix-specific extensions to File
fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>
Reads a number of bytes starting from a given offset.
Returns the number of bytes read.
The offset is relative to the start of the file and thus independent from the current cursor.
The current file cursor is not affected by this function.
Note that similar to File::read
, it is not an error to return with a short read.
fn write_at(&self, buf: &[u8], offset: u64) -> Result<usize>
Writes a number of bytes starting from a given offset.
Returns the number of bytes written.
The offset is relative to the start of the file and thus independent from the current cursor.
The current file cursor is not affected by this function.
When writing beyond the end of the file, the file is appropiately extended and the intermediate bytes are initialized with the value 0.
Note that similar to File::write
, it is not an error to return a short write.
impl FileExt for File
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/os/unix/fs/trait.FileExt.html