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 AsFd for RandomAccessFile
impl AsFd for RandomAccessFile
Source§fn as_fd(&self) -> BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
Source§impl AsRawFd for RandomAccessFile
impl AsRawFd for RandomAccessFile
Source§impl Debug for RandomAccessFile
impl Debug for RandomAccessFile
Source§impl From<File> for RandomAccessFile
impl From<File> for RandomAccessFile
Source§impl From<OwnedFd> for RandomAccessFile
impl From<OwnedFd> for RandomAccessFile
Source§impl From<RandomAccessFile> for File
impl From<RandomAccessFile> for File
Source§impl From<RandomAccessFile> for OwnedFd
impl From<RandomAccessFile> for OwnedFd
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 FromRawFd for RandomAccessFile
impl FromRawFd for RandomAccessFile
Source§unsafe fn from_raw_fd(fd: RawFd) -> Self
unsafe fn from_raw_fd(fd: RawFd) -> Self
Self
from the given raw file
descriptor. Read moreSource§impl IntoRawFd for RandomAccessFile
impl IntoRawFd for RandomAccessFile
Source§fn into_raw_fd(self) -> RawFd
fn into_raw_fd(self) -> RawFd
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