Module tokio::io

source · []
Expand description

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.

Utility functions

Utilities functions are provided for working with AsyncRead / AsyncWrite types. For example, copy asynchronously copies all data from a source to a destination.

std re-exports

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

Structs

A future which will copy all data from a reader into a writer.

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

A future used to fully flush an I/O object.

Combinator created by the top-level lines method which is a stream over the lines of text on an I/O object.

A future which can be used to easily read exactly enough bytes to fill a buffer.

The readable half of an object returned from AsyncRead::split.

A future which can be used to easily read the entire contents of a stream into a vector.

A future which can be used to easily read the contents of a stream into a vector until the delimiter is reached.

A future used to fully shutdown an I/O object.

A handle to the standard error stream of a process.

A handle to the standard input stream of a process.

A handle to the standard output stream of a process.

A future used to write the entire contents of some data to a stream.

The writable half of an object returned from AsyncRead::split.

Enums

A list specifying general categories of I/O error.

Traits

Read bytes asynchronously.

Writes bytes asynchronously.

The Read trait allows for reading bytes from a source.

A trait for objects which are byte-oriented sinks.

Functions

Creates a future which represents copying all the bytes from one object to another.

Creates a future which will entirely flush an I/O object and then yield the object itself.

Creates a new stream from the I/O object given representing the lines of input that are found on A.

Tries to read some bytes directly into the given buf in asynchronous manner, returning a future type.

Creates a future which will read exactly enough bytes to fill buf, returning an error if EOF is hit sooner.

Creates a future which will read all the bytes associated with the I/O object A into the buffer provided.

Creates a future which will read all the bytes associated with the I/O object A into the buffer provided until the delimiter byte is reached. This method is the async equivalent to BufRead::read_until.

Creates a future which will entirely shutdown an I/O object and then yield the object itself.

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

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

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

Creates a future that will write the entire contents of the buffer buf to the stream a provided.

Type Definitions

A specialized Result type for I/O operations.