Module std::memfs

An in-memory file system for tests: MemFs serves std::fs::Fs over the root's Loopback, whose file ops reach the simulated tree on every backend, interpreted and native, whatever the run's world. A #[test] installs it and runs a tool's with Fs code against files it made, the same way every time. The tree is empty when the run starts.

MemTree adds one op to Fs, root(), the tree's root directory. Only the code that installs MemFs holds MemTree; the code it calls with Fs reaches only the descriptors it is handed, as under std::fs's executors.

Source: std/memfs.weir; committed interface: std/memfs.iface. Index

effect MemTree

pub effect MemTree : Fs default portable migrates cross {
    once fn root() -> Result<Fd, Int>;
}

std::fs::Fs plus a way in: the root directory of the in-memory tree.

op root

once fn root() -> Result<Fd, Int>;

Control kind once: the clause takes the continuation (cont k) and resumes or cancels it, so the perform is a suspension and an abort edge.

The simulated tree's root, opened as a directory.

handler MemFs

pub handler MemFs(s: Slots<Unit, once>): shared cross for MemTree with Loopback

The in-memory file system: with MemFs(slots()) { let d = root(); … } (needs the root's Loopback; slots() is its table). The body is its one strand, one op in flight at a time.

Handles MemTree, with clauses: