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
impl RandomAccessFile
Sourcepub fn open<P: AsRef<Path>>(path: P) -> Result<RandomAccessFile>
pub fn open<P: AsRef<Path>>(path: P) -> Result<RandomAccessFile>
Attempts to open a file in read-only mode.
See File::open for details.
Sourcepub fn create<P: AsRef<Path>>(path: P) -> Result<RandomAccessFile>
pub fn create<P: AsRef<Path>>(path: P) -> Result<RandomAccessFile>
Opens a file in write-only mode.
See File::create for details.
Sourcepub fn sync_all(&self) -> Result<()>
pub fn sync_all(&self) -> Result<()>
Attempts to sync all OS-internal metadata to disk.
See File::sync_all for details.
Sourcepub fn sync_data(&self) -> Result<()>
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.
Sourcepub fn set_len(&self, size: u64) -> Result<()>
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.
Sourcepub fn metadata(&self) -> Result<Metadata>
pub fn metadata(&self) -> Result<Metadata>
Queries metadata about the underlying file.
See File::metadata for details.
Sourcepub fn try_clone(&self) -> Result<RandomAccessFile>
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.
Sourcepub fn set_permissions(&self, perm: Permissions) -> Result<()>
pub fn set_permissions(&self, perm: Permissions) -> Result<()>
Changes the permissions on the underlying file.
See File::set_permissions for details.
Sourcepub fn into_inner(self) -> File ⓘ
pub fn into_inner(self) -> File ⓘ
Unwraps the inner File.
The file’s cursor position is unspecified.
Trait Implementations§
Source§impl AsHandle for RandomAccessFile
Available on Windows only.
impl AsHandle for RandomAccessFile
Source§fn as_handle(&self) -> BorrowedHandle<'_>
fn as_handle(&self) -> BorrowedHandle<'_>
Source§impl AsRawHandle for RandomAccessFile
Available on Windows only.
impl AsRawHandle for RandomAccessFile
Source§fn as_raw_handle(&self) -> RawHandle
fn as_raw_handle(&self) -> RawHandle
Source§impl Debug for RandomAccessFile
impl Debug for RandomAccessFile
Source§impl From<File> for RandomAccessFile
impl From<File> for RandomAccessFile
Source§impl From<OwnedHandle> for RandomAccessFile
Available on Windows only.
impl From<OwnedHandle> for RandomAccessFile
Source§fn from(handle: OwnedHandle) -> Self
fn from(handle: OwnedHandle) -> Self
Source§impl From<RandomAccessFile> for File
impl From<RandomAccessFile> for File
Source§impl From<RandomAccessFile> for OwnedHandle
Available on Windows only.
impl From<RandomAccessFile> for OwnedHandle
Source§fn from(f: RandomAccessFile) -> Self
fn from(f: RandomAccessFile) -> Self
Source§impl From<RandomAccessFile> for SyncFile
impl From<RandomAccessFile> for SyncFile
Source§fn from(file: RandomAccessFile) -> SyncFile ⓘ
fn from(file: RandomAccessFile) -> SyncFile ⓘ
Creates a new SyncFile from an open RandomAccessFile.
The cursor starts at the beginning of the file.
Source§impl FromRawHandle for RandomAccessFile
Available on Windows only.
impl FromRawHandle for RandomAccessFile
Source§unsafe fn from_raw_handle(handle: RawHandle) -> Self
unsafe fn from_raw_handle(handle: RawHandle) -> Self
Source§impl IntoRawHandle for RandomAccessFile
Available on Windows only.
impl IntoRawHandle for RandomAccessFile
Source§fn into_raw_handle(self) -> RawHandle
fn into_raw_handle(self) -> RawHandle
Source§impl ReadAt for RandomAccessFile
impl ReadAt for RandomAccessFile
Source§fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>
fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>
Source§fn read_exact_at(&self, buf: &mut [u8], offset: u64) -> Result<()>
fn read_exact_at(&self, buf: &mut [u8], offset: u64) -> Result<()>
Source§fn read_vectored_at(
&self,
bufs: &mut [IoSliceMut<'_>],
offset: u64,
) -> Result<usize>
fn read_vectored_at( &self, bufs: &mut [IoSliceMut<'_>], offset: u64, ) -> Result<usize>
read_at, except that it reads into a slice of buffers. Read more