pub struct File { /* private fields */ }Expand description
High-performance async file handle with native implementation
Implementations§
Source§impl File
impl File
Sourcepub async fn open<P>(path: P) -> Result<File, Error>
pub async fn open<P>(path: P) -> Result<File, Error>
Open a file with default options (read-only)
Sourcepub async fn create<P>(path: P) -> Result<File, Error>
pub async fn create<P>(path: P) -> Result<File, Error>
Create a new file for writing (truncates if exists)
Sourcepub async fn open_with_options<P>(
path: P,
options: FileOpenOptions,
) -> Result<File, Error>
pub async fn open_with_options<P>( path: P, options: FileOpenOptions, ) -> Result<File, Error>
Open a file with custom options
Sourcepub async fn read_to_string(&mut self) -> Result<String, Error>
pub async fn read_to_string(&mut self) -> Result<String, Error>
Read entire file contents into a string
Sourcepub async fn read_to_end(&mut self) -> Result<Vec<u8>, Error>
pub async fn read_to_end(&mut self) -> Result<Vec<u8>, Error>
Read entire file contents into a byte vector
Sourcepub async fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
pub async fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Write all data from a buffer
Sourcepub async fn sync_all(&mut self) -> Result<(), Error>
pub async fn sync_all(&mut self) -> Result<(), Error>
Synchronize all data and metadata to disk
Sourcepub async fn sync_data(&mut self) -> Result<(), Error>
pub async fn sync_data(&mut self) -> Result<(), Error>
Synchronize data (but not metadata) to disk
Sourcepub async fn seek(&mut self, pos: SeekFrom) -> Result<u64, Error>
pub async fn seek(&mut self, pos: SeekFrom) -> Result<u64, Error>
Seek to a specific position in the file
Sourcepub async fn stream_position(&mut self) -> Result<u64, Error>
pub async fn stream_position(&mut self) -> Result<u64, Error>
Get current position in the file
Trait Implementations§
Source§impl AsyncWrite for File
impl AsyncWrite for File
Auto Trait Implementations§
impl Freeze for File
impl RefUnwindSafe for File
impl Send for File
impl Sync for File
impl Unpin for File
impl UnsafeUnpin for File
impl UnwindSafe for File
Blanket Implementations§
Source§impl<R> AsyncReadExt for R
impl<R> AsyncReadExt for R
Source§impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
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