pub trait FileIoExt: IoExt {
Show 21 methods fn advise(&self, offset: u64, len: u64, advice: Advice) -> Result<()>; fn allocate(&self, offset: u64, len: u64) -> Result<()>; fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>; fn read_exact_at(&self, buf: &mut [u8], offset: u64) -> Result<()>; fn read_to_end_at(&self, buf: &mut Vec<u8>, offset: u64) -> Result<usize>; fn read_to_string_at(&self, buf: &mut String, offset: u64) -> Result<usize>; fn write_at(&self, buf: &[u8], offset: u64) -> Result<usize>; fn append(&self, buf: &[u8]) -> Result<usize>; fn seek(&self, pos: SeekFrom) -> Result<u64>; fn stream_position(&self) -> Result<u64>; fn read_vectored_at(
        &self,
        bufs: &mut [IoSliceMut<'_>],
        offset: u64
    ) -> Result<usize> { ... } fn read_exact_vectored_at(
        &self,
        bufs: &mut [IoSliceMut<'_>],
        offset: u64
    ) -> Result<()> { ... } fn is_read_vectored_at(&self) -> bool { ... } fn write_all_at(&self, buf: &[u8], offset: u64) -> Result<()> { ... } fn write_vectored_at(
        &self,
        bufs: &[IoSlice<'_>],
        offset: u64
    ) -> Result<usize> { ... } fn write_all_vectored_at(
        &self,
        bufs: &mut [IoSlice<'_>],
        offset: u64
    ) -> Result<()> { ... } fn is_write_vectored_at(&self) -> bool { ... } fn append_all(&self, buf: &[u8]) -> Result<()> { ... } fn append_vectored(&self, bufs: &[IoSlice<'_>]) -> Result<usize> { ... } fn append_all_vectored(&self, bufs: &mut [IoSlice<'_>]) -> Result<()> { ... } fn is_append_vectored(&self) -> bool { ... }
}
Expand description

Extension trait for std::fs::File and cap_std::fs::File.

Required Methods§

Announce the expected access pattern of the data at the given offset.

Allocate space in the file, increasing the file size as needed, and ensuring that there are no holes under the given range.

Reads a number of bytes starting from a given offset.

This is similar to std::os::unix::fs::FileExt::read_at, except it takes self by immutable reference since the entire side effect is I/O, and it’s supported on non-Unix platforms including Windows.

Reads the exact number of byte required to fill buf from the given offset.

This is similar to std::os::unix::fs::FileExt::read_exact_at, except it takes self by immutable reference since the entire side effect is I/O, and it’s supported on non-Unix platforms including Windows.

Read all bytes, starting at offset, until EOF in this source, placing them into buf.

Read all bytes, starting at offset, until EOF in this source, appending them to buf.

Writes a number of bytes starting from a given offset.

This is similar to std::os::unix::fs::FileExt::write_at, except it takes self by immutable reference since the entire side effect is I/O, and it’s supported on non-Unix platforms including Windows.

A write past the end of the file extends the file with zero bytes until the point where the write starts.

Contrary to POSIX, on many popular platforms including Linux and FreeBSD, if the file is opened in append mode, this ignores the offset appends the data to the end of the file.

Writes a number of bytes at the end of a file.

This leaves the current position of the file unmodified.

This operation is not guaranteed to be atomic with respect to other users of the same open file description.

This operation is less efficient on some platforms than opening the file in append mode and doing regular writes.

Seek to an offset, in bytes, in a stream.

This is similar to std::io::Seek::seek, except it takes self by immutable reference since the entire side effect is I/O.

Returns the current seek position from the start of the stream.

This is similar to std::io::Seek::stream_position, except it’s available on Rust stable.

This may eventually be implemented by rust-lang/rust#62726.

Provided Methods§

Is to read_vectored what read_at is to read.

Is to read_exact_vectored what read_exact_at is to read_exact.

Determines if this FileIoExt implementation has an efficient read_vectored_at implementation.

Attempts to write an entire buffer starting from a given offset.

This is similar to std::os::unix::fs::FileExt::write_all_at, except it takes self by immutable reference since the entire side effect is I/O, and it’s supported on non-Unix platforms including Windows.

A write past the end of the file extends the file with zero bytes until the point where the write starts.

Contrary to POSIX, on many popular platforms including Linux and FreeBSD, if the file is opened in append mode, this ignores the offset appends the data to the end of the file.

Is to write_vectored what write_at is to write.

Is to write_all_vectored what write_all_at is to write_all.

Determines if this FileIoExt implementation has an efficient write_vectored_at implementation.

Attempts to write an entire buffer at the end of a file.

This leaves the current position of the file unmodified.

This operation is not guaranteed to be atomic with respect to other users of the same open file description.

This operation is less efficient on some platforms than opening the file in append mode and doing regular writes.

Is to append what write_vectored is to write.

Is to append_all what write_all_vectored is to write_all.

Determines if this FileIoExt implementation has an efficient append_vectored implementation.

Implementors§

Implement FileIoExt for any type which implements AsRawFd.