Linux x86_64, file io, flush, crash, space of possible states

Context: playing with some toy database / storage implementations.

Question:

For Rust IO crates, are there any that clearly specify the following:

  1. we open a file for read/write
  2. we issue some write ops (possibly including a flush)
  3. we do not yet get a "completed" message back
  4. system crashes

question: what is the space of all possible states the file system can be in ?

Possible answers are:

(1) ideal (but unrealistic) world: let F0 = last state we got a "write done"; let F! = new state we want; the file is at either F0 or F1

(2) also nice (but probably unrealistic world): let F0 = last state we got a "write done"; let d0, d1, ..., dn be the write commands we issued. The file is at F0 + d0 + d1 + d2 + ... + d_i for some i.

(3) no guarantees whatsoever (realistic but useless)

(4) maybe?: let F0 = last state we got a "write done"; let F1 = intended state; divide them into blocks of 4kb; on blocks that they agree, the blocks guarnteed to stay the same; on blocks they disagree, no guarantee ....

Question: do any Rust crates doing IO on linux x86_64 make any form of useful guarantees of the form:

last good state = F0; we are writing towards F1; machine crashes, ... we guarantee the following properties about the half written file ... ?

[ It is file to have separate answers opened in append-only mode, mmap mode, etc ... ]