pub struct BackupStore { /* private fields */ }Expand description
Per-file undo store with optional disk persistence.
When storage_dir is set, backups persist to disk so undo history
survives bridge and OpenCode restarts. Disk layout:
<storage_dir>/backups/<path_hash>/meta.json — file path + count
<storage_dir>/backups/<path_hash>/0.bak … 19.bak — content snapshots
Implementations§
Source§impl BackupStore
impl BackupStore
pub fn new() -> Self
Sourcepub fn set_storage_dir(&mut self, dir: PathBuf)
pub fn set_storage_dir(&mut self, dir: PathBuf)
Set storage directory for disk persistence (called during configure).
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.
Sourcepub fn restore_latest(
&mut self,
path: &Path,
) -> Result<(BackupEntry, Option<String>), AftError>
pub fn restore_latest( &mut self, path: &Path, ) -> Result<(BackupEntry, Option<String>), AftError>
Pop the most recent backup for path and restore the file contents.
Returns (entry, optional_warning).
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 disk_history_count(&self, path: &Path) -> usize
pub fn disk_history_count(&self, path: &Path) -> usize
Return the number of on-disk backup entries for a file.
Sourcepub fn tracked_files(&self) -> Vec<PathBuf>
pub fn tracked_files(&self) -> Vec<PathBuf>
Return all files that have at least one backup entry (memory + disk).
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