pub struct RandomAccessFile(/* private fields */);
Expand description

A file with cross-platform positioned I/O.

Reading from this file or writing to it does not use its internal OS cursor, but it may move it anyway. This can cause surprising behaviour if shared with a File (this could be done with try_clone).

Implementations§

source§

impl RandomAccessFile

source

pub fn open<P: AsRef<Path>>(path: P) -> Result<RandomAccessFile>

Attempts to open a file in read-only mode.

See File::open for details.

source

pub fn create<P: AsRef<Path>>(path: P) -> Result<RandomAccessFile>

Opens a file in write-only mode.

See File::create for details.

source

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

Attempts to sync all OS-internal metadata to disk.

See File::sync_all for details.

source

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

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

See File::sync_data for details.

source

pub fn set_len(&self, size: u64) -> Result<()>

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

See File::set_len for details.

source

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

Queries metadata about the underlying file.

See File::metadata for details.

source

pub fn try_clone(&self) -> Result<RandomAccessFile>

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

See File::try_clone for details.

source

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

Changes the permissions on the underlying file.

See File::set_permissions for details.

source

pub fn into_inner(self) -> File

Unwraps the inner File.

The file’s cursor position is unspecified.

Trait Implementations§

source§

impl AsFd for RandomAccessFile

source§

fn as_fd(&self) -> BorrowedFd<'_>

Borrows the file descriptor. Read more
source§

impl AsRawFd for RandomAccessFile

source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
source§

impl Debug for RandomAccessFile

source§

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

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

impl From<File> for RandomAccessFile

source§

fn from(file: File) -> RandomAccessFile

Creates a new RandomAccessFile from an open File.

source§

impl From<OwnedFd> for RandomAccessFile

source§

fn from(fd: OwnedFd) -> Self

Converts to this type from the input type.
source§

impl From<RandomAccessFile> for File

source§

fn from(file: RandomAccessFile) -> File

Converts to this type from the input type.
source§

impl From<RandomAccessFile> for OwnedFd

source§

fn from(f: RandomAccessFile) -> Self

Converts to this type from the input type.
source§

impl From<RandomAccessFile> for SyncFile

source§

fn from(file: RandomAccessFile) -> SyncFile

Creates a new SyncFile from an open RandomAccessFile.

The cursor starts at the beginning of the file.

source§

impl FromRawFd for RandomAccessFile

source§

unsafe fn from_raw_fd(fd: RawFd) -> Self

Constructs a new instance of Self from the given raw file descriptor. Read more
source§

impl IntoRawFd for RandomAccessFile

source§

fn into_raw_fd(self) -> RawFd

Consumes this object, returning the raw underlying file descriptor. Read more
source§

impl ReadAt for RandomAccessFile

source§

fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>

Reads a number of bytes starting from a given offset. Read more
source§

fn read_exact_at(&self, buf: &mut [u8], offset: u64) -> Result<()>

Reads the exact number of byte required to fill buf from the given offset. Read more
source§

fn read_vectored_at( &self, bufs: &mut [IoSliceMut<'_>], offset: u64 ) -> Result<usize>

Like read_at, except that it reads into a slice of buffers. Read more
source§

impl WriteAt for RandomAccessFile

source§

fn write_at(&self, buf: &[u8], offset: u64) -> Result<usize>

Writes a number of bytes starting from a given offset. Read more
source§

fn write_all_at(&self, buf: &[u8], offset: u64) -> Result<()>

Attempts to write an entire buffer starting from a given offset. Read more
source§

fn flush(&self) -> Result<()>

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
source§

fn write_vectored_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> Result<usize>

Like write_at, except that it writes from a slice of buffers. Read more

Auto Trait Implementations§

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<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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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