I found the asyncfile module in the std lib, but I'm still wondering whether it is ready for use, since there's no doc for it.
And there's a more specific problem.
I tried to use that module in my program but found that, strangely, the AsyncFile type is not exported at all, so I couldn't, say, embed that type in my own objects.
I assume there's no special reason for hiding the AsyncFile type, right?
You are right. The AsyncFile type should be exported. I just pushed a fix for this.
The module is finished but I can't speak for its stability as I have not used it extensively. Let me know if you find any more problems, here is an example to get you started:
import asyncfile, asyncdispatch, os
proc main() {.async.} =
var file = openAsync(getTempDir() / "foobar.txt", fmReadWrite)
await file.write("test")
file.setFilePos(0)
let data = await file.readAll()
doAssert data == "test"
file.close()
waitFor main()