[][src]Module tokio::io

Asynchronous I/O.

This module is the asynchronous version of std::io. Primarily, it defines two traits, AsyncRead and AsyncWrite, which extend the Read and Write traits of the standard library.

AsyncRead and AsyncWrite

AsyncRead and AsyncWrite must only be implemented for non-blocking I/O types that integrate with the futures type system. In other words, these types must never block the thread, and instead the current task is notified when the I/O resource is ready.

Standard input and output

Tokio provides asynchronous APIs to standard input, output, and error. These APIs are very similar to the ones provided by std, but they also implement AsyncRead and AsyncWrite.

Unlike most other Tokio APIs, the standard input / output APIs must be used from the context of the Tokio runtime as they require Tokio specific features to function.

std re-exports

Additionally, Error, ErrorKind, and Result are re-exported from std::io for ease of use.

Structs

BufReader

The BufReader struct adds buffering to any reader.

BufWriter

Wraps a writer and buffers its output.

Error

The error type for I/O operations of the Read, Write, Seek, and associated traits.

Stderr

A handle to the standard error stream of a process.

Stdin

A handle to the standard input stream of a process.

Stdout

A handle to the standard output stream of a process.

Enums

ErrorKind

A list specifying general categories of I/O error.

Traits

AsyncBufRead

Read bytes asynchronously.

AsyncBufReadExt

An extension trait which adds utility methods to AsyncBufRead types.

AsyncRead

Read bytes asynchronously.

AsyncReadExt

An extension trait which adds utility methods to AsyncRead types.

AsyncWrite

Writes bytes asynchronously.

AsyncWriteExt

An extension trait which adds utility methods to AsyncWrite types.

Functions

split

Split a single value implementing AsyncRead + AsyncWrite into separate AsyncRead and AsyncWrite handles.

stderr

Constructs a new handle to the standard error of the current process.

stdin

Constructs a new handle to the standard input of the current process.

stdout

Constructs a new handle to the standard output of the current process.

Type Definitions

Result

A specialized Result type for I/O operations.