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_tx: TxId, epoch: EpochId) -> Result<()>
pub fn checkpoint(&self, current_tx: TxId, 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.