pub struct WalManager { /* private fields */ }Expand description
Manages the Write-Ahead Log with rotation, checkpointing, and durability modes.
Implementations§
Source§impl WalManager
impl WalManager
Sourcepub fn open(dir: impl AsRef<Path>) -> Result<Self>
pub fn open(dir: impl AsRef<Path>) -> Result<Self>
Opens or creates a WAL in the given directory.
§Errors
Returns an error if the directory cannot be created or accessed.
Sourcepub fn with_config(dir: impl AsRef<Path>, config: WalConfig) -> Result<Self>
pub fn with_config(dir: impl AsRef<Path>, config: WalConfig) -> Result<Self>
Opens or creates a WAL with custom configuration.
§Errors
Returns an error if the directory cannot be created or accessed.
Sourcepub fn checkpoint(
&self,
current_transaction: TransactionId,
epoch: EpochId,
) -> Result<()>
pub fn checkpoint( &self, current_transaction: TransactionId, epoch: EpochId, ) -> Result<()>
Writes a checkpoint marker and persists checkpoint metadata.
The checkpoint metadata is written atomically to a separate file, allowing recovery to skip WAL files that precede the checkpoint.
§Errors
Returns an error if the checkpoint cannot be written.
Sourcepub fn read_checkpoint_metadata(&self) -> Result<Option<CheckpointMetadata>>
pub fn read_checkpoint_metadata(&self) -> Result<Option<CheckpointMetadata>>
Reads checkpoint metadata from disk.
Returns None if no checkpoint metadata exists.
Sourcepub fn record_count(&self) -> u64
pub fn record_count(&self) -> u64
Returns the total number of records written.
Sourcepub fn durability_mode(&self) -> DurabilityMode
pub fn durability_mode(&self) -> DurabilityMode
Returns the current durability mode.
Sourcepub fn log_files(&self) -> Result<Vec<PathBuf>>
pub fn log_files(&self) -> Result<Vec<PathBuf>>
Returns all WAL log file paths in sequence order.
Sourcepub fn checkpoint_epoch(&self) -> Option<EpochId>
pub fn checkpoint_epoch(&self) -> Option<EpochId>
Returns the latest checkpoint epoch, if any.
Sourcepub fn size_bytes(&self) -> usize
pub fn size_bytes(&self) -> usize
Returns the total size of all WAL files in bytes.
Sourcepub fn last_checkpoint_timestamp(&self) -> Option<u64>
pub fn last_checkpoint_timestamp(&self) -> Option<u64>
Returns the timestamp of the last checkpoint (Unix epoch seconds), if any.
Sourcepub fn close_active_log(&self)
pub fn close_active_log(&self)
Closes the active log file, releasing its file handle.
This allows the WAL directory to be safely removed on Windows, where open file handles prevent directory deletion. A new log file will be created automatically on the next write.
Auto Trait Implementations§
impl !Freeze for WalManager
impl !RefUnwindSafe for WalManager
impl Send for WalManager
impl Sync for WalManager
impl Unpin for WalManager
impl UnsafeUnpin for WalManager
impl UnwindSafe for WalManager
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more