pub struct HistoryProtection { /* private fields */ }Expand description
Protection layer for history to prevent data loss
Implementations§
Source§impl HistoryProtection
impl HistoryProtection
pub fn new(backup_dir: PathBuf) -> Self
Sourcepub fn backup_before_write(&self, current_data: &str, entry_count: usize)
pub fn backup_before_write(&self, current_data: &str, entry_count: usize)
Create a backup of current history before any write operation
Sourcepub fn validate_write(
&self,
old_entries: usize,
new_entries: usize,
new_data: &str,
) -> bool
pub fn validate_write( &self, old_entries: usize, new_entries: usize, new_data: &str, ) -> bool
Validate that new history data is safe to write
Sourcepub fn recover_from_backup(&self) -> Option<String>
pub fn recover_from_backup(&self) -> Option<String>
Attempt to recover from the most recent backup
Auto Trait Implementations§
impl Freeze for HistoryProtection
impl RefUnwindSafe for HistoryProtection
impl Send for HistoryProtection
impl Sync for HistoryProtection
impl Unpin for HistoryProtection
impl UnwindSafe for HistoryProtection
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
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>
Converts
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>
Converts
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