• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H28-Apr-2020-766

benches/H28-Apr-2020-280229

bin/H28-Apr-2020-241198

ci/H28-Apr-2020-494417

examples/H28-Apr-2020-1,543900

tests-build/H28-Apr-2020-10075

tests-integration/H28-Apr-2020-261190

tokio/H28-Apr-2020-58,89832,769

tokio-macros/H28-Apr-2020-749502

tokio-test/H28-Apr-2020-1,204776

tokio-tls/H28-Apr-2020-1,4591,134

tokio-util/H28-Apr-2020-4,6852,878

.cirrus.ymlH A D28-Apr-20201.3 KiB4338

.gitignoreH A D28-Apr-202018 32

CODE_OF_CONDUCT.mdH A D28-Apr-2020361 84

CONTRIBUTING.mdH A D28-Apr-202019 KiB444335

Cargo.tomlH A D28-Apr-2020184 1613

LICENSEH A D28-Apr-20201 KiB2622

README.mdH A D28-Apr-20205.8 KiB167121

ROADMAP.mdH A D28-Apr-20202.9 KiB6849

azure-pipelines.ymlH A D28-Apr-20202.2 KiB116101

README.md

1# Tokio
2
3A runtime for writing reliable, asynchronous, and slim applications with
4the Rust programming language. It is:
5
6* **Fast**: Tokio's zero-cost abstractions give you bare-metal
7  performance.
8
9* **Reliable**: Tokio leverages Rust's ownership, type system, and
10  concurrency model to reduce bugs and ensure thread safety.
11
12* **Scalable**: Tokio has a minimal footprint, and handles backpressure
13  and cancellation naturally.
14
15[![Crates.io][crates-badge]][crates-url]
16[![MIT licensed][mit-badge]][mit-url]
17[![Build Status][azure-badge]][azure-url]
18[![Discord chat][discord-badge]][discord-url]
19
20[crates-badge]: https://img.shields.io/crates/v/tokio.svg
21[crates-url]: https://crates.io/crates/tokio
22[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg
23[mit-url]: LICENSE
24[azure-badge]: https://dev.azure.com/tokio-rs/Tokio/_apis/build/status/tokio-rs.tokio?branchName=master
25[azure-url]: https://dev.azure.com/tokio-rs/Tokio/_build/latest?definitionId=1&branchName=master
26[discord-badge]: https://img.shields.io/discord/500028886025895936.svg?logo=discord&style=flat-square
27[discord-url]: https://discord.gg/tokio
28
29[Website](https://tokio.rs) |
30[Guides](https://tokio.rs/docs/overview/) |
31[API Docs](https://docs.rs/tokio/latest/tokio) |
32[Roadmap](https://github.com/tokio-rs/tokio/blob/master/ROADMAP.md) |
33[Chat](https://discord.gg/tokio)
34
35## Overview
36
37Tokio is an event-driven, non-blocking I/O platform for writing
38asynchronous applications with the Rust programming language. At a high
39level, it provides a few major components:
40
41* A multithreaded, work-stealing based task [scheduler].
42* A reactor backed by the operating system's event queue (epoll, kqueue,
43  IOCP, etc...).
44* Asynchronous [TCP and UDP][net] sockets.
45
46These components provide the runtime components necessary for building
47an asynchronous application.
48
49[net]: https://docs.rs/tokio/latest/tokio/net/index.html
50[scheduler]: https://docs.rs/tokio/latest/tokio/runtime/index.html
51
52## Example
53
54A basic TCP echo server with Tokio:
55
56```rust,no_run
57use tokio::net::TcpListener;
58use tokio::prelude::*;
59
60#[tokio::main]
61async fn main() -> Result<(), Box<dyn std::error::Error>> {
62    let mut listener = TcpListener::bind("127.0.0.1:8080").await?;
63
64    loop {
65        let (mut socket, _) = listener.accept().await?;
66
67        tokio::spawn(async move {
68            let mut buf = [0; 1024];
69
70            // In a loop, read data from the socket and write the data back.
71            loop {
72                let n = match socket.read(&mut buf).await {
73                    // socket closed
74                    Ok(n) if n == 0 => return,
75                    Ok(n) => n,
76                    Err(e) => {
77                        eprintln!("failed to read from socket; err = {:?}", e);
78                        return;
79                    }
80                };
81
82                // Write the data back
83                if let Err(e) = socket.write_all(&buf[0..n]).await {
84                    eprintln!("failed to write to socket; err = {:?}", e);
85                    return;
86                }
87            }
88        });
89    }
90}
91```
92
93More examples can be found [here](examples).
94
95## Getting Help
96
97First, see if the answer to your question can be found in the [Guides] or the
98[API documentation]. If the answer is not there, there is an active community in
99the [Tokio Discord server][chat]. We would be happy to try to answer your
100question. Last, if that doesn't work, try opening an [issue] with the question.
101
102[Guides]: https://tokio.rs/docs/
103[API documentation]: https://docs.rs/tokio/latest/tokio
104[chat]: https://discord.gg/tokio
105[issue]: https://github.com/tokio-rs/tokio/issues/new
106
107## Contributing
108
109:balloon: Thanks for your help improving the project! We are so happy to have
110you! We have a [contributing guide][guide] to help you get involved in the Tokio
111project.
112
113[guide]: https://github.com/tokio-rs/tokio/blob/master/CONTRIBUTING.md
114
115## Related Projects
116
117In addition to the crates in this repository, the Tokio project also maintains
118several other libraries, including:
119
120* [`hyper`]: A fast and correct HTTP/1.1 and HTTP/2 implementation for Rust.
121
122* [`tonic`]: A gRPC over HTTP/2 implementation focused on high performance, interoperability, and flexibility.
123
124* [`warp`]: A super-easy, composable, web server framework for warp speeds.
125
126* [`tower`]: A library of modular and reusable components for building robust networking clients and servers.
127
128* [`tracing`] (formerly `tokio-trace`): A framework for application-level
129  tracing and async-aware diagnostics.
130
131* [`rdbc`]: A Rust database connectivity library for MySQL, Postgres and SQLite.
132
133* [`mio`]: A low-level, cross-platform abstraction over OS I/O APIs that powers
134  `tokio`.
135
136* [`bytes`]: Utilities for working with bytes, including efficient byte buffers.
137
138* [`loom`]: A testing tool for concurrent Rust code
139
140[`warp`]: https://github.com/seanmonstar/warp
141[`hyper`]: https://github.com/hyperium/hyper
142[`tonic`]: https://github.com/hyperium/tonic
143[`tower`]: https://github.com/tower-rs/tower
144[`loom`]: https://github.com/tokio-rs/loom
145[`rdbc`]: https://github.com/tokio-rs/rdbc
146[`tracing`]: https://github.com/tokio-rs/tracing
147[`mio`]: https://github.com/tokio-rs/mio
148[`bytes`]: https://github.com/tokio-rs/bytes
149
150## Supported Rust Versions
151
152Tokio is built against the latest stable, nightly, and beta Rust releases. The
153minimum version supported is the stable release from three months before the
154current stable release version. For example, if the latest stable Rust is 1.29,
155the minimum version supported is 1.26. The current Tokio version is not
156guaranteed to build on Rust versions earlier than the minimum supported version.
157
158## License
159
160This project is licensed under the [MIT license](LICENSE).
161
162### Contribution
163
164Unless you explicitly state otherwise, any contribution intentionally submitted
165for inclusion in Tokio by you, shall be licensed as MIT, without any additional
166terms or conditions.
167