Learn Async Rust

There is no standard / official Asynchronous runtime. This in contrast to actual CPU threads which you can create from within the std library.

The most popular and recommended by many Async Runtime is the Tokio runtime. Which brings us to the next chapter:

Please also join the Tokio Discord community as part of your async Journey, a place where you can ask any questions you want as well: https://discord.com/invite/tokio. This server also has individual channels for the different projects in the Tokio ecosystem such as Hyper, Axum, Tower and more. The maintainers of the different projects are also very active in the server and are happy to help you out, but of course please do not take this for granted. Be respectful and if possible contribute back to the community as well.

The following article is a very nice introduction to Rust async: https://ibraheem.ca/posts/too-many-web-servers/.

Extra Learning Resources:

At https://without.boats/blog/why-async-rust/ you can reat more thoughts on Async rust, its history and its implementation.

As an extra, and perhaps slightly sidetracked, you may also want to read and develop alongside the following articles:

In order to help you understand how Async code works (e.g. what about the Async keyword and How do futures really work. And how do you define traits with futures. And How do you implement them), you might want to read through the articles linked in the Tower section, as seeing how to implement your own Tower middleware might answer many of such questions. Gaining a deeper theoretical but still pragmatic enough understanding behind it is probably better done by reading some of the books listed in this guide.

ⓘ Note: Tokio also provides support to the new Linux kernel io_uring concept, a new powerful way to allow async programming on Linux. Support for it can be found at: GitHub - tokio-rs/tokio-uring: An io_uring backed runtime for Rust

Synacktiv made an IO network scanner using io_uring as can be seen at GitHub - synacktiv/io_uring_scanner: io_uring based network scanner written in Rust, using tokio's low level userspace bindings to io_uring.

To get a better idea about how futures work and the executor which polls them, you might want to read this article: https://bertptrs.nl/2023/04/27/how-does-async-rust-work.html.

The blog series as found at https://hegdenu.net/posts/understanding-async-await-1/ can be another great reference to help you understand the entire async/await part of Rust:

Sooner or later you'll also start to see the conterversy surrounding Async, while most do agree it's a a great thing to be and have, and also acknowledge the hard work that is put into it, but not about all implementation details people agree. One such detail is about whether we really need async fn syntax, an interesting take about that can be read at https://seanmonstar.com/post/66832922686/was-async-fn-a-mistake. Like always follow interesting blogs, and news resources such as "This week in Rust".

There are currently not yet async iterators. An interesting blog series that can help you get a grasp of what async iterators might look like or to get you start thinking on it is the following series by "Yoshua Wuyts":

  1. Async Iteration I: Semantics (2020): https://blog.yoshuawuyts.com/async-iteration/
  2. Async Iteration II: Async Iterator Crate (2022): https://blog.yoshuawuyts.com/async-iterator-crate/
  3. Async Iteration III: The Async Iterator Trait (2023): https://blog.yoshuawuyts.com/async-iterator-trait/