Expand description
Filesystem-backed kv backend (M4.C — DS-14-storage Audit 4).
FileBackend maps each key to a .bin file under a configured directory.
Keys are percent-encoded so any UTF-8 string can be stored safely:
[a-zA-Z0-9_-] pass through; everything else is UTF-8 encoded with each
byte formatted as lowercase %xx. The encoded filename for any given key
is byte-identical to the TS fileBackend impl
(packages/pure-ts/src/extra/storage/tiers-node.ts — D159) so a TS-written
file can be loaded by a Rust reader on the same directory.
Writes are atomic via tempfile::NamedTempFile::persist: a tempfile is
created in the target directory, written in full, then renamed onto the
key path. A partially-written file is never visible at the final path,
even on process crash. The NamedTempFile Drop impl deletes any tempfile
that never made it through persist (covers panics between create and
commit).
flush() is a no-op — durability is on per-write basis via the rename.
read / delete / list tolerate missing directory + missing key by
returning Ok(None) / Ok(()) / Ok(vec![]) respectively (D158).
Cargo feature: gated behind file (default-on).
Structs§
- File
Backend - Filesystem-backed
StorageBackend.
Functions§
- file_
append_ log - Convenience: append-log tier over a fresh file backend rooted at
dir. - file_
append_ log_ default - Convenience: append-log tier over a fresh file backend with
AppendLogStorageOptions::default+ aJsonCodec. - file_
backend - Convenience constructor returning an
Arc<FileBackend>. Use this when sharing a single backend across multiple tiers (the paired{ snapshot, wal }pattern from DS-14-storage §a). For non-default configuration useArc::new(FileBackend::new(dir).with_include_hidden(true)). - file_kv
- Convenience: kv tier over a fresh file backend rooted at
dir. - file_
kv_ default - Convenience: kv tier over a fresh file backend with
KvStorageOptions::default+ aJsonCodec. - file_
snapshot - Convenience: snapshot tier over a fresh file backend rooted at
dir. Mirror ofcrate::memory_snapshotfor filesystem persistence. - file_
snapshot_ default - Convenience: snapshot tier over a fresh file backend with
SnapshotStorageOptions::default+ aJsonCodec.