pub struct WalRecovery { /* private fields */ }Expand description
Handles WAL recovery after a crash.
Implementations§
Source§impl WalRecovery
impl WalRecovery
Sourcepub fn new(dir: impl AsRef<Path>) -> Self
pub fn new(dir: impl AsRef<Path>) -> Self
Creates a new recovery handler for the given WAL directory.
Sourcepub fn from_wal(wal: &WalManager) -> Self
pub fn from_wal(wal: &WalManager) -> Self
Creates a recovery handler from a WAL manager.
Sourcepub fn read_checkpoint_metadata(&self) -> Result<Option<CheckpointMetadata>>
pub fn read_checkpoint_metadata(&self) -> Result<Option<CheckpointMetadata>>
Reads checkpoint metadata if it exists.
Returns None if no checkpoint metadata is found.
Sourcepub fn checkpoint(&self) -> Option<CheckpointMetadata>
pub fn checkpoint(&self) -> Option<CheckpointMetadata>
Returns the checkpoint metadata, if any.
This is useful for determining whether to perform a full or incremental recovery.
Sourcepub fn recover(&self) -> Result<Vec<WalRecord>>
pub fn recover(&self) -> Result<Vec<WalRecord>>
Recovers committed records from all WAL files.
Returns only records that were part of committed transactions. If checkpoint metadata exists, only replays files from the checkpoint sequence onwards.
§Errors
Returns an error if recovery fails.
Sourcepub fn recover_from_checkpoint(
&self,
checkpoint: Option<&CheckpointMetadata>,
) -> Result<Vec<WalRecord>>
pub fn recover_from_checkpoint( &self, checkpoint: Option<&CheckpointMetadata>, ) -> Result<Vec<WalRecord>>
Recovers committed records, starting from a specific checkpoint.
This can be used for incremental recovery when you want to skip WAL files that precede the checkpoint.
§Errors
Returns an error if recovery fails.