Struct sync_file::RandomAccessFile
source · 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