Struct compio_fs::File

source ·
pub struct File { /* private fields */ }
Expand description

A reference to an open file on the filesystem.

An instance of a File can be read and/or written depending on what options it was opened with. The File type provides positional read and write operations. The file does not maintain an internal cursor. The caller is required to specify an offset when issuing an operation.

Implementations§

source§

impl File

source

pub async fn open(path: impl AsRef<Path>) -> Result<Self>

Attempts to open a file in read-only mode.

See the OpenOptions::open method for more details.

source

pub async fn create(path: impl AsRef<Path>) -> Result<Self>

Opens a file in write-only mode.

This function will create a file if it does not exist, and will truncate it if it does.

See the OpenOptions::open function for more details.

source

pub fn close(self) -> impl Future<Output = Result<()>>

Close the file. If the returned future is dropped before polling, the file won’t be closed.

source

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

Available on Windows only.

Queries metadata about the underlying file.

source

pub async fn set_permissions(&self, perm: Permissions) -> Result<()>

Available on Windows only.

Changes the permissions on the underlying file.

source

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

Attempts to sync all OS-internal metadata to disk.

This function will attempt to ensure that all in-memory data reaches the filesystem before returning.

source

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

This function is similar to sync_all, except that it might not synchronize file metadata to the filesystem.

This is intended for use cases that must synchronize content, but don’t need the metadata on disk. The goal of this method is to reduce disk operations.

Note that some platforms may simply implement this in terms of sync_all.

Trait Implementations§

source§

impl AsRawFd for File

source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw fd.
source§

impl AsRawHandle for File

Available on Windows only.
source§

fn as_raw_handle(&self) -> RawHandle

Extracts the raw handle. Read more
source§

impl AsyncReadAt for File

source§

async fn read_at<T: IoBufMut>(&self, buffer: T, pos: u64) -> BufResult<usize, T>

Like AsyncRead::read, except that it reads at a specified position.
source§

async fn read_vectored_at<T>(&self, buf: T, pos: u64) -> BufResult<usize, T>

Like AsyncRead::read_vectored, except that it reads at a specified position.
source§

impl AsyncWriteAt for &File

source§

async fn write_at<T: IoBuf>( &mut self, buffer: T, pos: u64, ) -> BufResult<usize, T>

Like AsyncWrite::write, except that it writes at a specified position.
source§

async fn write_vectored_at<T>( &mut self, buf: T, pos: u64, ) -> BufResult<usize, T>
where T: IoVectoredBuf,

Like AsyncWrite::write_vectored, except that it writes at a specified position.
source§

impl AsyncWriteAt for File

source§

async fn write_at<T: IoBuf>(&mut self, buf: T, pos: u64) -> BufResult<usize, T>

Like AsyncWrite::write, except that it writes at a specified position.
source§

async fn write_vectored_at<T>( &mut self, buf: T, pos: u64, ) -> BufResult<usize, T>
where T: IoVectoredBuf,

Like AsyncWrite::write_vectored, except that it writes at a specified position.
source§

impl Clone for File

source§

fn clone(&self) -> File

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. 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 FromRawHandle for File

Available on Windows only.
source§

unsafe fn from_raw_handle(handle: RawHandle) -> Self

Constructs a new I/O object from the specified raw handle. Read more
source§

impl ToSharedFd<File> for File

source§

fn to_shared_fd(&self) -> SharedFd<File>

Return a cloned SharedFd.

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<A> AsyncReadAtExt for A
where A: AsyncReadAt + ?Sized,

source§

async fn read_exact_at<T>(&self, buf: T, pos: u64) -> BufResult<(), T>
where T: IoBufMut,

Read the exact number of bytes required to fill buffer. Read more
source§

async fn read_to_end_at( &self, buffer: Vec<u8>, pos: u64, ) -> BufResult<usize, Vec<u8>>

Read all bytes until EOF in this source, placing them into buffer. Read more
source§

async fn read_vectored_exact_at<T>(&self, buf: T, pos: u64) -> BufResult<(), T>

Like AsyncReadExt::read_vectored_exact, expect that it reads at a specified position.
source§

impl<A> AsyncWriteAtExt for A
where A: AsyncWriteAt + ?Sized,

source§

async fn write_all_at<T>(&mut self, buf: T, pos: u64) -> BufResult<(), T>
where T: IoBuf,

Like AsyncWriteAt::write_at, except that it tries to write the entire contents of the buffer into this writer.
source§

async fn write_vectored_all_at<T>( &mut self, buf: T, pos: u64, ) -> BufResult<(), T>
where T: IoVectoredBuf,

Like AsyncWriteAt::write_vectored_at, expect that it tries to write the entire contents of the buffer into this writer.
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where 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> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

source§

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 T
where U: TryFrom<T>,

source§

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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more