pub struct FileHandleGuard<'a> { /* private fields */ }Expand description
RAII guard providing access to the file while the latch is held.
Implementations§
Source§impl<'a> FileHandleGuard<'a>
impl<'a> FileHandleGuard<'a>
Sourcepub fn read_exact_at(&mut self, offset: u64, buf: &mut [u8]) -> Result<()>
pub fn read_exact_at(&mut self, offset: u64, buf: &mut [u8]) -> Result<()>
Reads exactly buf.len() bytes from the file at the given offset.
Uses pread64 in a retry loop.
Returns an error if fewer bytes are available.
Sourcepub fn write_at(&mut self, offset: u64, buf: &[u8]) -> Result<usize>
pub fn write_at(&mut self, offset: u64, buf: &[u8]) -> Result<usize>
Writes data to the file at the given offset.
Uses pwrite64 (one syscall) instead of lseek + write (two syscalls).
FileChannel.write(ByteBuffer, position) which the JVM
lowers to pwrite64 on Linux. This eliminates half the syscalls on
the hot write path and removes the need to serialise seek+write under
the guard (pwrite64 is inherently positional and thread-safe).
§Arguments
offset- File offset to write to (passed directly to pwrite64)buf- Data to write
§Returns
Number of bytes written (always buf.len() on success).
Sourcepub fn sync(&mut self) -> Result<()>
pub fn sync(&mut self) -> Result<()>
Syncs all file data and metadata to disk (fsync).
Use this when the file’s metadata (size, mtime) must also be durable —
typically for file-header writes. For log-data writes prefer
sync_data() which is faster.
Sourcepub fn sync_data(&mut self) -> Result<()>
pub fn sync_data(&mut self) -> Result<()>
Syncs only the file data to disk (fdatasync).
Faster than sync() because it does not flush file metadata (mtime
etc.). uses FileChannel.force(false) (= fdatasync) for all
log-data writes and force(true) (= fsync) only for file-header writes.
/ FileChannel.force(false).
Sourcepub fn log_version(&self) -> u32
pub fn log_version(&self) -> u32
Returns the log version.