pub struct File { /* private fields */ }
Expand description
An opened file object, with open permissions and a cursor.
Implementations§
source§impl File
impl File
sourcepub fn open(path: &str, opts: &OpenOptions) -> AxResult<Self>
pub fn open(path: &str, opts: &OpenOptions) -> AxResult<Self>
Opens a file at the path relative to the current directory. Returns a
File
object.
sourcepub fn read(&mut self, buf: &mut [u8]) -> AxResult<usize>
pub fn read(&mut self, buf: &mut [u8]) -> AxResult<usize>
Reads the file at the current position. Returns the number of bytes read.
After the read, the cursor will be advanced by the number of bytes read.
sourcepub fn read_at(&self, offset: u64, buf: &mut [u8]) -> AxResult<usize>
pub fn read_at(&self, offset: u64, buf: &mut [u8]) -> AxResult<usize>
Reads the file at the given position. Returns the number of bytes read.
It does not update the file cursor.
sourcepub fn write(&mut self, buf: &[u8]) -> AxResult<usize>
pub fn write(&mut self, buf: &[u8]) -> AxResult<usize>
Writes the file at the current position. Returns the number of bytes written.
After the write, the cursor will be advanced by the number of bytes written.
sourcepub fn write_at(&self, offset: u64, buf: &[u8]) -> AxResult<usize>
pub fn write_at(&self, offset: u64, buf: &[u8]) -> AxResult<usize>
Writes the file at the given position. Returns the number of bytes written.
It does not update the file cursor.
sourcepub fn flush(&self) -> AxResult
pub fn flush(&self) -> AxResult
Flushes the file, writes all buffered data to the underlying device.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for File
impl !RefUnwindSafe for File
impl Send for File
impl Sync for File
impl Unpin for File
impl !UnwindSafe for File
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more