Expand description

Asynchronous File I/O module for Tokio

This module provides methods for asynchronous file I/O. On BSD-based operating systems, it uses mio-aio. On Linux, it could use libaio, but that isn’t implemented yet.


use std::fs;
use std::io::Read;
use tempfile::TempDir;
use tokio::runtime;

let contents = b"abcdef";
let mut rbuf = Vec::new();

let dir = TempDir::new().unwrap();
let path = dir.path().join("foo");
let file = fs::OpenOptions::new()
let rt = runtime::Builder::new_current_thread()
let r = rt.block_on(async {
    file.write_at(contents, 0).unwrap().await
assert_eq!(r.value.unwrap() as usize, contents.len());

let mut file = fs::File::open(&path).unwrap();
assert_eq!(file.read_to_end(&mut rbuf).unwrap(), contents.len());
assert_eq!(&contents[..], &rbuf[..]);


A Future representing an AIO operation.

Holds the result of an individual aio operation

Basically a Tokio file handle. This is the starting point for tokio-file.

The return value of File::readv_at

The return value of File::writev_at