pub struct MoveTransaction {
pub file_snapshots: HashMap<PathBuf, String>,
pub copied_destination: Option<PathBuf>,
pub source_removed: bool,
pub source_path: PathBuf,
pub destination_path: PathBuf,
/* private fields */
}Expand description
Tracks all filesystem mutations so they can be rolled back on failure.
The transaction records three kinds of operations:
- File snapshots – original content of files that will be modified in-place.
- Copied destination – the new file created by
fs::copy. - Removed source – set after the original file is deleted, so rollback can restore it.
Fields§
§file_snapshots: HashMap<PathBuf, String>§copied_destination: Option<PathBuf>§source_removed: bool§source_path: PathBuf§destination_path: PathBufImplementations§
Source§impl MoveTransaction
impl MoveTransaction
pub fn new(source_path: PathBuf, destination_path: PathBuf) -> Self
Sourcepub fn snapshot_file(&mut self, path: &Path) -> Result<()>
pub fn snapshot_file(&mut self, path: &Path) -> Result<()>
Snapshot a file’s current content before modifying it.
Sourcepub fn mark_copied(&mut self)
pub fn mark_copied(&mut self)
Record that the destination file was created via copy.
Sourcepub fn mark_renamed(&mut self)
pub fn mark_renamed(&mut self)
Record that the source path was renamed to the destination path.
Sourcepub fn mark_source_removed(&mut self)
pub fn mark_source_removed(&mut self)
Record that the source file has been removed.
Auto Trait Implementations§
impl Forget for MoveTransaction
impl Freeze for MoveTransaction
impl Move for MoveTransaction
impl RefUnwindSafe for MoveTransaction
impl Send for MoveTransaction
impl Sync for MoveTransaction
impl Unpin for MoveTransaction
impl UnsafeUnpin for MoveTransaction
impl UnwindSafe for MoveTransaction
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