val to_file : ?limit:int -> ?atomic:bool -> FS.t -> temp_dir:Fpath.t -> Fpath.t -> Cstruct.t -> E.state -> (E.result, error) Stdlib.result Lwt.tto_file t f tmp state encodes state in the file f using tmp as an intermediary buffer.
The result is Error `Stack if at least limit writes have returned 0.
If atomic is set, the operation is guaranteed to be atomic.