pub struct BackupStore { /* private fields */ }Expand description
Per-file undo store backed by an in-memory stack.
Keys are canonical paths (resolved via std::fs::canonicalize with fallback
to cleaned relative path). Each file maps to a stack of BackupEntry values
ordered oldest-first so restore_latest pops from the end.
Implementations§
Source§impl BackupStore
impl BackupStore
pub fn new() -> Self
Sourcepub fn snapshot(
&mut self,
path: &Path,
description: &str,
) -> Result<String, AftError>
pub fn snapshot( &mut self, path: &Path, description: &str, ) -> Result<String, AftError>
Snapshot the current contents of path with a description.
Returns the generated backup ID. Fails with FileNotFound if the file
cannot be read.
Sourcepub fn restore_latest(&mut self, path: &Path) -> Result<BackupEntry, AftError>
pub fn restore_latest(&mut self, path: &Path) -> Result<BackupEntry, AftError>
Pop the most recent backup for path and restore the file contents.
Returns the restored entry. Fails with NoUndoHistory if no backups
exist for the path.
Sourcepub fn history(&self, path: &Path) -> Vec<BackupEntry>
pub fn history(&self, path: &Path) -> Vec<BackupEntry>
Return the backup history for a file (oldest first).
Sourcepub fn tracked_files(&self) -> Vec<PathBuf>
pub fn tracked_files(&self) -> Vec<PathBuf>
Return all files that have at least one backup entry.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for BackupStore
impl RefUnwindSafe for BackupStore
impl Send for BackupStore
impl Sync for BackupStore
impl Unpin for BackupStore
impl UnsafeUnpin for BackupStore
impl UnwindSafe for BackupStore
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> 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