1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// vim: tw=80
//! 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.
//!
//! # Examples
//!
//! ```
//! use std::borrow::Borrow;
//! use std::fs;
//! use std::io::Read;
//! use tempdir::TempDir;
//! use tokio::runtime::current_thread;
//!
//! let contents = b"abcdef";
//! let wbuf: Box<Borrow<[u8]>> = Box::new(&contents[..]);
//! let mut rbuf = Vec::new();
//!
//! let dir = TempDir::new("tokio-file").unwrap();
//! let path = dir.path().join("foo");
//! let file = fs::OpenOptions::new()
//!     .create(true)
//!     .write(true)
//!     .open(&path)
//!     .map(tokio_file::File::new)
//!     .unwrap();
//! let mut rt = current_thread::Runtime::new().unwrap();
//! let r = rt.block_on(
//!     file.write_at(wbuf, 0).unwrap()
//! ).unwrap();
//! assert_eq!(r.value.unwrap() as usize, contents.len());
//! drop(file);
//!
//! let mut file = fs::File::open(&path).unwrap();
//! assert_eq!(file.read_to_end(&mut rbuf).unwrap(), contents.len());
//! assert_eq!(&contents[..], &rbuf[..]);
//! ```

mod file;

pub use file::{AioFut, AioResult, BufRef, File, LioFut, LioResult};