pub struct FileTransaction { /* private fields */ }Expand description
Transaction manager for atomic file operations
Thread-safe: allows multiple threads to perform atomic writes concurrently. Atomic: either all writes succeed and are committed, or all are rolled back.
Implementations§
Source§impl FileTransaction
impl FileTransaction
Sourcepub fn with_backup_dir(backup_dir: impl AsRef<Path>) -> Result<Self>
pub fn with_backup_dir(backup_dir: impl AsRef<Path>) -> Result<Self>
Create a new transaction with backup directory
Sourcepub fn write_file(&self, path: impl AsRef<Path>, content: &str) -> Result<()>
pub fn write_file(&self, path: impl AsRef<Path>, content: &str) -> Result<()>
Write file atomically - either succeeds completely or has no effect
Uses temp file + rename for atomic operation:
- Write to temporary file
- Atomically rename to target (OS-level atomic operation)
- Track operation for potential rollback
Sourcepub fn commit(self) -> Result<TransactionReceipt>
pub fn commit(self) -> Result<TransactionReceipt>
Commit transaction - mark as successful
After commit, backups are kept but rollback is disabled
Trait Implementations§
Source§impl Debug for FileTransaction
impl Debug for FileTransaction
Source§impl Drop for FileTransaction
impl Drop for FileTransaction
Auto Trait Implementations§
impl !Freeze for FileTransaction
impl !RefUnwindSafe for FileTransaction
impl Send for FileTransaction
impl Sync for FileTransaction
impl Unpin for FileTransaction
impl UnsafeUnpin for FileTransaction
impl UnwindSafe for FileTransaction
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> EvidenceKind for T
impl<T> EvidenceKind for T
default fn kind_label(&self) -> &'static str
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