I don't see an equivalent of async pwrite/pread (write at a specified offset) in async_std or in the tokio APIs. How do folks typically deal with this? The standard RUST API does have it but of course it is synchronous.
tokio
has an AsyncRead
and an AsyncWrite
trait. async-std
similarly has async versions of Read
and Write
.
These libraries also have structs which implement these traits and are used to perform async IO. For an instance, the File
struct in tokio
implements both AsyncRead
and AsyncWrite
and can be used as-such.
Generally, async file IO is implemented by just wrapping the std call in spawn_blocking
, so you can do the same by calling the ordinary pwrite
method from within spawn_blocking
.
3 Likes
Perfect. Thanks.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.