I/O

I/O in Tokio operates in much the same way as std, but asynchronously. There is a trait for reading (AsyncRead) and a trait for writing (AsyncWrite). Specific types implement these traits as appropriate (TcpStream, File, Stdout). AsyncRead and AsyncWrite are also implemented by a number of data structures, such as Vec<u8> and &[u8]. This allows using byte arrays where a reader or writer is expected.

This page will cover basic I/O reading and writing with Tokio and work through a few examples. The next page will get into a more advanced I/O example.