pub struct File { /* private fields */ }
tokio
only.Expand description
Wrapper around tokio::fs::File
which adds more helpful
information to all errors.
Implementations§
source§impl File
impl File
sourcepub async fn open(path: impl Into<PathBuf>) -> Result<File>
pub async fn open(path: impl Into<PathBuf>) -> Result<File>
Attempts to open a file in read-only mode.
Wrapper for tokio::fs::File::open
.
sourcepub async fn create(path: impl Into<PathBuf>) -> Result<File>
pub async fn create(path: impl Into<PathBuf>) -> Result<File>
Opens a file in write-only mode.
Wrapper for tokio::fs::File::create
.
sourcepub fn from_std(std: File) -> File
pub fn from_std(std: File) -> File
Converts a crate::File
to a tokio::fs::File
.
Wrapper for tokio::fs::File::from_std
.
sourcepub async fn sync_all(&self) -> Result<()>
pub async fn sync_all(&self) -> Result<()>
Attempts to sync all OS-internal metadata to disk.
Wrapper for tokio::fs::File::sync_all
.
sourcepub async fn sync_data(&self) -> Result<()>
pub async fn sync_data(&self) -> Result<()>
This function is similar to sync_all
, except that it may not
synchronize file metadata to the filesystem.
Wrapper for tokio::fs::File::sync_data
.
sourcepub async fn set_len(&self, size: u64) -> Result<()>
pub async fn set_len(&self, size: u64) -> Result<()>
Truncates or extends the underlying file, updating the size of this file to become size.
Wrapper for tokio::fs::File::set_len
.
sourcepub async fn metadata(&self) -> Result<Metadata>
pub async fn metadata(&self) -> Result<Metadata>
Queries metadata about the underlying file.
Wrapper for tokio::fs::File::metadata
.
sourcepub async fn try_clone(&self) -> Result<File>
pub async fn try_clone(&self) -> Result<File>
Creates a new File
instance that shares the same underlying file handle
as the existing File
instance. Reads, writes, and seeks will affect both
File
instances simultaneously.
Wrapper for tokio::fs::File::try_clone
.
sourcepub async fn into_std(self) -> File ⓘ
pub async fn into_std(self) -> File ⓘ
Destructures File
into a crate::File
. This function is async to allow any
in-flight operations to complete.
Wrapper for tokio::fs::File::into_std
.
sourcepub fn try_into_std(self) -> Result<File, File>
pub fn try_into_std(self) -> Result<File, File>
Tries to immediately destructure File
into a crate::File
.
Wrapper for tokio::fs::File::try_into_std
.
sourcepub async fn set_permissions(&self, perm: Permissions) -> Result<()>
pub async fn set_permissions(&self, perm: Permissions) -> Result<()>
Changes the permissions on the underlying file.
Wrapper for tokio::fs::File::set_permissions
.
source§impl File
impl File
Methods added by fs-err that are not available on
tokio::fs::File
.
sourcepub fn from_parts<P>(file: TokioFile, path: P) -> Selfwhere
P: Into<PathBuf>,
pub fn from_parts<P>(file: TokioFile, path: P) -> Selfwhere P: Into<PathBuf>,
Creates a File
from a raw file and its path.
sourcepub fn into_parts(self) -> (TokioFile, PathBuf)
pub fn into_parts(self) -> (TokioFile, PathBuf)
Extract the raw file and its path from this File
.
sourcepub fn file(&self) -> &TokioFile
pub fn file(&self) -> &TokioFile
Returns a reference to the underlying tokio::fs::File
.
sourcepub fn file_mut(&mut self) -> &mut TokioFile
pub fn file_mut(&mut self) -> &mut TokioFile
Returns a mutable reference to the underlying tokio::fs::File
.
Trait Implementations§
source§impl AsyncWrite for File
impl AsyncWrite for File
source§fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize>>
buf
into the object. Read moresource§fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
source§fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
source§fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>]
) -> Poll<Result<usize>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize>>
poll_write
, except that it writes from a slice of buffers. Read moresource§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
poll_write_vectored
implementation. Read more