Skip to main content

Crate fstx

Crate fstx 

Source
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_with and crate::recover_with.
RecoveryReport
What crate::recover did.
RelPath
A path relative to the root: a list of single, non-empty OS-native components.
TokenInspection
TokenPosition
Transaction
A set of changes to a directory tree that becomes visible all at once, or not at all.
TxInspection

Enums§

Error
Every error fstx can return.
RecoveryAction
What crate::recover would do with a transaction.

Functions§

inspect
Read-only report of what recover would do. Never modifies anything.
inspect_on
inspect on a custom vfs::Vfs.
recover
Recovers every interrupted transaction under root (also done by Transaction::begin).
recover_on
recover on a custom vfs::Vfs.
recover_with

Type Aliases§

Result
Result alias used throughout the crate.