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_as<R: WalEntry>(&self) -> Result<Vec<R>>
pub fn recover_as<R: WalEntry>(&self) -> Result<Vec<R>>
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.
Auto Trait Implementations§
impl Freeze for WalRecovery
impl RefUnwindSafe for WalRecovery
impl Send for WalRecovery
impl Sync for WalRecovery
impl Unpin for WalRecovery
impl UnsafeUnpin for WalRecovery
impl UnwindSafe for WalRecovery
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