pub struct FileHandle { /* private fields */ }Expand description
A file handle with latch protection for thread-safe I/O.
The handle holds a file descriptor and an exclusive latch. All I/O operations must be performed while holding the latch.
Implementations§
Source§impl FileHandle
impl FileHandle
Sourcepub fn new(file_num: u32) -> Self
pub fn new(file_num: u32) -> Self
Creates a new uninitialized file handle.
The file must be initialized via init() before use.
Sourcepub fn init(&mut self, file: File, log_version: u32)
pub fn init(&mut self, file: File, log_version: u32)
Initializes the handle with an open file and log version.
Sourcepub fn log_version(&self) -> u32
pub fn log_version(&self) -> u32
Returns the log version.
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Returns true if the file is initialized.
Sourcepub fn acquire(&self) -> Result<FileHandleGuard<'_>>
pub fn acquire(&self) -> Result<FileHandleGuard<'_>>
Acquires the latch and returns a guard that provides access to the file.
Returns Ok(guard) on success, or Err(LogError::LatchTimeout) if the
latch acquisition times out. The latch is released when the guard drops.
Sourcepub fn try_acquire(&self) -> Option<FileHandleGuard<'_>>
pub fn try_acquire(&self) -> Option<FileHandleGuard<'_>>
Attempts to acquire the latch without blocking.
Returns None if the latch is currently held.
Trait Implementations§
Source§impl Drop for FileHandle
impl Drop for FileHandle
Auto Trait Implementations§
impl !Freeze for FileHandle
impl !RefUnwindSafe for FileHandle
impl !UnwindSafe for FileHandle
impl Send for FileHandle
impl Sync for FileHandle
impl Unpin for FileHandle
impl UnsafeUnpin for FileHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more