Expand description
§fstx — atomic, crash-safe multi-file transactions
Stage any number of writes, renames and removals inside a directory tree, then
commit: after any crash, recover leaves the tree exactly in
its before-state or exactly in its after-state (after only if commit returned Ok).
let mut tx = fstx::Transaction::begin("./project")?;
tx.write("config.toml", b"version = 2\n")?;
tx.create_dir_all("src/gen")?;
tx.rename("old.rs", "src/gen/new.rs")?;
tx.remove("tmp.log")?;
tx.commit()?;How it works, the exact guarantees, and the assumptions they rest on are in
DESIGN.md. In short: every change to the tree is a no-replace rename of an entry
whose identity was recorded in a durable journal beforehand; renames run in waves
separated by fsync barriers; recovery locates entries by identity and undoes waves in
reverse under the same discipline.
The real-filesystem backend is Linux-only in v0.1; on other platforms
Transaction::begin returns Error::UnsupportedPlatform.
Modules§
- vfs
- The filesystem abstraction the protocol is written against.
Structs§
- Caps
- What the probe learned about the filesystem.
- Inspection
- State of the root’s private area.
- Options
- Options for
Transaction::begin_withandcrate::recover_with. - Recovery
Report - What
crate::recoverdid. - RelPath
- A path relative to the root: a list of single, non-empty OS-native components.
- Token
Inspection - Token
Position - Transaction
- A set of changes to a directory tree that becomes visible all at once, or not at all.
- TxInspection
Enums§
- Error
- Every error
fstxcan return. - Recovery
Action - What
crate::recoverwould do with a transaction.
Functions§
- inspect
- Read-only report of what
recoverwould do. Never modifies anything. - inspect_
on inspecton a customvfs::Vfs.- recover
- Recovers every interrupted transaction under
root(also done byTransaction::begin). - recover_
on recoveron a customvfs::Vfs.- recover_
with
Type Aliases§
- Result
- Result alias used throughout the crate.