Struct fs_err::tokio::File

source ·
pub struct File { /* private fields */ }
Available on crate feature tokio only.
Expand description

Wrapper around tokio::fs::File which adds more helpful information to all errors.

Implementations§

source§

impl File

source

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.

source

pub async fn create(path: impl Into<PathBuf>) -> Result<File>

Opens a file in write-only mode.

Wrapper for tokio::fs::File::create.

source

pub fn from_std(std: File) -> File

source

pub async fn sync_all(&self) -> Result<()>

Attempts to sync all OS-internal metadata to disk.

Wrapper for tokio::fs::File::sync_all.

source

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.

source

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.

source

pub async fn metadata(&self) -> Result<Metadata>

Queries metadata about the underlying file.

Wrapper for tokio::fs::File::metadata.

source

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.

source

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.

source

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.

source

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

Methods added by fs-err that are not available on tokio::fs::File.

source

pub fn from_parts<P>(file: TokioFile, path: P) -> Selfwhere P: Into<PathBuf>,

Creates a File from a raw file and its path.

source

pub fn into_parts(self) -> (TokioFile, PathBuf)

Extract the raw file and its path from this File.

source

pub fn file(&self) -> &TokioFile

Returns a reference to the underlying tokio::fs::File.

source

pub fn file_mut(&mut self) -> &mut TokioFile

Returns a mutable reference to the underlying tokio::fs::File.

source

pub fn path(&self) -> &Path

Returns a reference to the path that this file was created with.

Trait Implementations§

source§

impl AsRawHandle for File

source§

fn as_raw_handle(&self) -> RawHandle

Extracts the raw handle. Read more
source§

impl AsyncRead for File

source§

fn poll_read( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_> ) -> Poll<Result<()>>

Attempts to read from the AsyncRead into buf. Read more
source§

impl AsyncSeek for File

source§

fn start_seek(self: Pin<&mut Self>, position: SeekFrom) -> Result<()>

Attempts to seek to an offset, in bytes, in a stream. Read more
source§

fn poll_complete( self: Pin<&mut Self>, cx: &mut Context<'_> ) -> Poll<Result<u64>>

Waits for a seek operation to complete. Read more
source§

impl AsyncWrite for File

source§

fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize>>

Attempt to write bytes from buf into the object. Read more
source§

fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>

Attempts to flush the object, ensuring that any buffered data reach their destination. Read more
source§

fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>

Initiates or attempts to shut down this writer, returning success when the I/O connection has completely shut down. Read more
source§

fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>] ) -> Poll<Result<usize>>

Like poll_write, except that it writes from a slice of buffers. Read more
source§

fn is_write_vectored(&self) -> bool

Determines if this writer has an efficient poll_write_vectored implementation. Read more
source§

impl Debug for File

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<File> for File

source§

fn from(f: File) -> Self

Converts to this type from the input type.
source§

impl From<File> for File

source§

fn from(f: File) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.