Struct cap_std::fs::File

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

A reference to an open file on a filesystem.

This corresponds to std::fs::File.

This File has no open or create methods. To open or create a file, first obtain a Dir containing the path, and then call Dir::open or Dir::create.

Implementations

Constructs a new instance of Self from the given std::fs::File.

This grants access the resources the std::fs::File instance already has access to.

Consumes self and returns a std::fs::File.

Attempts to sync all OS-internal metadata to disk.

This corresponds to std::fs::File::sync_all.

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

This corresponds to std::fs::File::sync_data.

Truncates or extends the underlying file, updating the size of this file to become size.

This corresponds to std::fs::File::set_len.

Queries metadata about the underlying file.

This corresponds to std::fs::File::metadata.

Creates a new File instance that shares the same underlying file handle as the existing File instance.

This corresponds to std::fs::File::try_clone.

Changes the permissions on the underlying file.

This corresponds to std::fs::File::set_permissions.

Constructs a new instance of Self in read-only mode by opening the given path as a file using the host process’ ambient authority.

Ambient Authority

This function is not sandboxed and may access any path that the host process has access to.

Constructs a new instance of Self with the options specified by options by opening the given path as a file using the host process’ ambient authority.

Ambient Authority

This function is not sandboxed and may access any path that the host process has access to.

Returns a new OpenOptions object.

This corresponds to std::fs::File::options.

Trait Implementations

Borrows the file descriptor. Read more
Extracts the raw file descriptor. Read more
Formats the value using the given formatter. Read more
Reads a number of bytes starting from a given offset. Read more
Writes a number of bytes starting from a given offset. Read more
Reads the exact number of byte required to fill buf from the given offset. Read more
Attempts to write an entire buffer starting from a given offset. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Constructs a new instance of Self from the given raw file descriptor. Read more
Consumes this object, returning the raw underlying file descriptor. Read more
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Like read, except that it reads into a slice of buffers. Read more
Read the exact number of bytes required to fill buf. Read more
Read all bytes until EOF in this source, placing them into buf. Read more
Read all bytes until EOF in this source, appending them to buf. Read more
🔬This is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. Read more
🔬This is a nightly-only experimental API. (read_buf)
Pull some bytes from this source into the specified buffer. Read more
🔬This is a nightly-only experimental API. (read_buf)
Read the exact number of bytes required to fill cursor. Read more
Creates a “by reference” adaptor for this instance of Read. Read more
Transforms this Read instance to an Iterator over its bytes. Read more
Creates an adapter which will chain this stream with another. Read more
Creates an adapter which will read at most limit bytes from it. Read more
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Like read, except that it reads into a slice of buffers. Read more
Read the exact number of bytes required to fill buf. Read more
Read all bytes until EOF in this source, placing them into buf. Read more
Read all bytes until EOF in this source, appending them to buf. Read more
🔬This is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. Read more
🔬This is a nightly-only experimental API. (read_buf)
Pull some bytes from this source into the specified buffer. Read more
🔬This is a nightly-only experimental API. (read_buf)
Read the exact number of bytes required to fill cursor. Read more
Creates a “by reference” adaptor for this instance of Read. Read more
Transforms this Read instance to an Iterator over its bytes. Read more
Creates an adapter which will chain this stream with another. Read more
Creates an adapter which will read at most limit bytes from it. Read more
Seek to an offset, in bytes, in a stream. Read more
Returns the current seek position from the start of the stream. Read more
Rewind to the beginning of a stream. Read more
🔬This is a nightly-only experimental API. (seek_stream_len)
Returns the length of this stream (in bytes). Read more
Seek to an offset, in bytes, in a stream. Read more
Returns the current seek position from the start of the stream. Read more
Rewind to the beginning of a stream. Read more
🔬This is a nightly-only experimental API. (seek_stream_len)
Returns the length of this stream (in bytes). Read more
Write a buffer into this writer, returning how many bytes were written. Read more
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
Like write, except that it writes from a slice of buffers. Read more
Attempts to write an entire buffer into this writer. Read more
🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
Writes a formatted string into this writer, returning any error encountered. Read more
Creates a “by reference” adapter for this instance of Write. Read more
Write a buffer into this writer, returning how many bytes were written. Read more
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
Like write, except that it writes from a slice of buffers. Read more
Attempts to write an entire buffer into this writer. Read more
🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
Writes a formatted string into this writer, returning any error encountered. Read more
Creates a “by reference” adapter for this instance of Write. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Borrows the reference. Read more
Return a borrowing view of a resource which dereferences to a &Target. Read more
Extracts the grip.
Returns the raw value.
Extracts the raw grip.
Returns the raw value.
Borrows the reference.
Return a borrowing view of a resource which dereferences to a &Target. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

👎Deprecated since 1.0.0: FromFd::from_fd is replaced by From<OwnedFd>::from
Constructs a new instance of Self from the given file descriptor. Read more
Constructs a new instance of Self from the given file descriptor converted from into_owned. Read more
Constructs a new instance of Self from the given filelike object. Read more
Constructs a new instance of Self from the given filelike object converted from into_owned. Read more
Consume an OwnedGrip and convert into a Self.
Constructs Self from the raw value. Read more
Consume an RawGrip and convert into a Self. Read more
Constructs Self from the raw value. Read more
Constructs a new instance of Self from the given socketlike object.
Constructs a new instance of Self from the given socketlike object converted from into_owned. Read more

Calls U::from(self).

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

👎Deprecated since 1.0.0: IntoFd is replaced by From<...> for OwnedFd or Into<OwnedFd>
Consumes this object, returning the underlying file descriptor. Read more
Consumes this object, returning the underlying filelike object. Read more
Consume self and convert into an OwnedGrip.
Returns the raw value.
Consume self and convert into an RawGrip.
Returns the raw value.
Consumes this object, returning the underlying socketlike object.
Set the last access and last modification timestamps of an open file handle. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.