I want to write program that save several megabytes to disk and report to user that "all ok, your data is safe".
So if after my program report that all ok powerloss happens or something like this, data in file should not be lost or damanged with high probability.
As I know on Linux you most probably get this done by using:
You will want to do some reading on the std::fs module for file operations. You can perform your normal file operations there, and anything in that module is cross-platform.
To abstract over some of the byte-level operations, you probably want to look at the std::io module. It contains several good options for making reading and writing to streams of any type (including from files) more ergonomic.
FWIW I’ve opened an issue on GH asking for clarification whether
this is intentional.
[0] The second fsync() call is actually the only necessary
operation that is unavailable in std. For files there is .sync_all() but no analogue seems to exist for directory
handles.