Tokio uses feature flags to reduce compiled code size and dependencies. By default, Tokio enables no features, allowing you to opt into only what you need.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tokio-rs/tokio/llms.txt
Use this file to discover all available pages before exploring further.
Quick Start
For application development, use thefull feature to enable everything:
Cargo.toml
Cargo.toml
The
full feature does not include test-util or unstable features like io-uring and taskdump.Core Features
rt - Basic Runtime
rt - Basic Runtime
Enables This is the minimal feature needed to run async tasks. Use this for the single-threaded current-thread scheduler.
tokio::spawn, the current-thread scheduler, and non-scheduler utilities.rt-multi-thread - Multi-threaded Runtime
rt-multi-thread - Multi-threaded Runtime
Enables the multi-threaded, work-stealing scheduler.Use this for production applications that need to utilize multiple CPU cores.
macros - Convenience Macros
macros - Convenience Macros
Enables This feature depends on the
#[tokio::main] and #[tokio::test] macros.tokio-macros crate.I/O Features
| Feature | Description | Key Types |
|---|---|---|
| net | TCP, UDP, and Unix Domain Sockets | TcpStream, UdpSocket, UnixStream |
| io-util | Utility traits and combinators for async I/O | AsyncReadExt, AsyncWriteExt |
| io-std | Async stdin, stdout, and stderr | Stdin, Stdout, Stderr |
| fs | Async filesystem operations | File, read, write, read_dir |
Network Example
Cargo.toml
The
AsyncRead and AsyncWrite traits are always available and don’t require any feature flags.Synchronization and Time
| Feature | Description | Key Types |
|---|---|---|
| sync | Async synchronization primitives | Mutex, RwLock, mpsc, oneshot, watch, broadcast, Barrier, Semaphore |
| time | Time-related utilities | sleep, interval, timeout, Instant, Duration |
Synchronization Example
Cargo.toml
Time Example
Cargo.toml
System Features
| Feature | Description | Platforms |
|---|---|---|
| process | Spawn and manage child processes | Unix, Windows |
| signal | Async signal handling | Unix, Windows |
Process Example
Cargo.toml
Special Features
test-util
Enables testing utilities for the Tokio runtime.Cargo.toml
parking_lot
Optimizes internal synchronization primitives using theparking_lot crate.
Cargo.toml
This is a performance optimization. It also allows constructing some primitives in
const context. MSRV may increase based on parking_lot releases.Unstable Features
Some features require the--cfg tokio_unstable flag and may have breaking API changes.
Enabling Unstable Features
Add to.cargo/config.toml:
.cargo/config.toml
Available Unstable Features
| Feature | Description | Platform |
|---|---|---|
| tracing | Enables tracing events for debugging | All |
| io-uring | Linux io_uring support for high-performance I/O | Linux only |
| taskdump | Task dump debugging capabilities | Linux (aarch64, x86, x86_64) |
io-uring Example
Cargo.toml
.cargo/config.toml
Complete Feature Table
| Feature | Default | Included in full | Unstable | Dependencies |
|---|---|---|---|---|
| rt | ❌ | ✅ | ❌ | - |
| rt-multi-thread | ❌ | ✅ | ❌ | rt |
| net | ❌ | ✅ | ❌ | mio, socket2 |
| io-util | ❌ | ✅ | ❌ | bytes |
| io-std | ❌ | ✅ | ❌ | - |
| fs | ❌ | ✅ | ❌ | - |
| sync | ❌ | ✅ | ❌ | - |
| time | ❌ | ✅ | ❌ | - |
| macros | ❌ | ✅ | ❌ | tokio-macros |
| process | ❌ | ✅ | ❌ | bytes, signal-hook-registry |
| signal | ❌ | ✅ | ❌ | signal-hook-registry |
| parking_lot | ❌ | ✅ | ❌ | parking_lot |
| test-util | ❌ | ❌ | ❌ | rt, sync, time |
| tracing | ❌ | ❌ | ✅ | tracing |
| io-uring | ❌ | ❌ | ✅ | io-uring, libc, slab |
| taskdump | ❌ | ❌ | ✅ | backtrace |
Choosing Features
For Applications
Usefull for convenience during development: