mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-16 00:00:12 +02:00
Disabling all features means the only dependency is `futures`. Relevant pieces of the API can then be enabled with the following features: - `codec` - `fs` - `io` - `reactor` - `tcp` - `timer` - `udp` - `uds` This also introduces the beginnings of enabling only certain pieces of the `Runtime`. As a start, the entire default runtime API is enabled via the `rt-full` feature.
96 lines
2.4 KiB
Rust
96 lines
2.4 KiB
Rust
//! 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.
|
|
//!
|
|
//! [input]: fn.stdin.html
|
|
//! [output]: fn.stdout.html
|
|
//! [error]: fn.stderr.html
|
|
//!
|
|
//! # 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.
|
|
//!
|
|
//! [`AsyncRead`]: trait.AsyncRead.html
|
|
//! [`AsyncWrite`]: trait.AsyncWrite.html
|
|
//! [`copy`]: fn.copy.html
|
|
//! [`Read`]: trait.Read.html
|
|
//! [`Write`]: trait.Write.html
|
|
//! [`Error`]: struct.Error.html
|
|
//! [`ErrorKind`]: enum.ErrorKind.html
|
|
//! [`Result`]: type.Result.html
|
|
|
|
pub use tokio_io::{
|
|
AsyncRead,
|
|
AsyncWrite,
|
|
};
|
|
|
|
// standard input, output, and error
|
|
#[cfg(feature = "fs")]
|
|
pub use tokio_fs::{
|
|
stdin,
|
|
Stdin,
|
|
stdout,
|
|
Stdout,
|
|
stderr,
|
|
Stderr,
|
|
};
|
|
|
|
// Utils
|
|
pub use tokio_io::io::{
|
|
copy,
|
|
Copy,
|
|
flush,
|
|
Flush,
|
|
lines,
|
|
Lines,
|
|
read,
|
|
read_exact,
|
|
ReadExact,
|
|
read_to_end,
|
|
ReadToEnd,
|
|
read_until,
|
|
ReadUntil,
|
|
ReadHalf,
|
|
shutdown,
|
|
Shutdown,
|
|
write_all,
|
|
WriteAll,
|
|
WriteHalf,
|
|
};
|
|
|
|
// Re-export io::Error so that users don't have to deal
|
|
// with conflicts when `use`ing `futures::io` and `std::io`.
|
|
pub use ::std::io::{
|
|
Error,
|
|
ErrorKind,
|
|
Result,
|
|
Read,
|
|
Write,
|
|
};
|