Rust Tutorial - The What and How of Futures and async/await in Rust

Rust Tutorial - The What and How of Futures and async/await in Rust

Futures are Rust's way of expressing asynchronous computations, but even after reading the documentation, it can be hard to figure out how all the pieces of futures (and tokio) fit together. While this may not matter too much if you're just *using* futures, it becomes a stumbling block once you want to implement asynchronous primitives yourself. The highly anticipated async and await keywords that are coming down the pike promise to greatly reduce the friction of writing and using asynchronous code, but add even more to the mystery of how this stuff all works. Rust Tutorial - The What and How of Futures and async/await in Rust

Futures are Rust's way of expressing asynchronous computations, but even after reading the documentation, it can be hard to figure out how all the pieces of futures (and tokio) fit together. While this may not matter too much if you're just using futures, it becomes a stumbling block once you want to implement asynchronous primitives yourself. The highly anticipated async and await keywords that are coming down the pike promise to greatly reduce the friction of writing and using asynchronous code, but add even more to the mystery of how this stuff all works.

NOTE: The YouTube transcoding process seems to have introduce audio lag on all the non-1080p versions. I'll report it to YT, but if it's bothering you, the 1080p version works fine :)

In this stream, we tackle all of this head on. We go through what futures are, how they work, how they are used to represent things like asynchronous I/O (like networking), how they are executed, and how they are evolving as they are being adopted into the standard library. We also discuss async/await, and how they affect futures, and how Rust's proposed pinning types act as the glue to make async/await work.

This is pretty dense material, but hopefully serves as a good and thorough overview of futures in Rust. If you want to know how it all works, this stream probably has you covered! To help you navigate, here are the major transition points:

0:00:00 - Introduction 0:05:57 - What are futures? 0:16:39 - How are futures executed? 0:26:10 - Super weird audio problems 0:29:09 - All good again! (you didn't miss anything) 0:50:04 - How do you integrate futures with I/O? 1:36:11 - Driving futures with Tokio 1:49:28 - Multi-threaded future execution 2:15:00 - Stream and Sink 2:17:11 - (brief aside about tokio-io-pool) 2:24:07 - Putting futures in the standard library 2:30:00 - Arbitrary self types 2:33:46 - What is async/await? 2:46:58 - Why is async/await hard? 2:53:34 - Self-referential data-types 2:58:48 - Pinning! 3:50:40 - Q&A

The tokio documentation push is being organized at https://github.com/tokio-rs/doc-push .

rust

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Rust Casting, Shadowing, Consts and Static

A mix of topics of casting, shadowing, constants and static variables inside the Rust Programming Language. This Rust programming language tutorial series is aimed at easing your training step by step.

Rust Zürichsee, April: Gerhard Bräunlich - PyO3 and Rust in action

This presentation was the first experiment with livestreaming of the Rust Zürisee meetup group in Switzerland. Gerhard is sharing parts of his story migratin...

"Rust Isn’t Afraid to be Imperfect as Long as we Ship something Useful"

Steve Klabnik is a member of the Rust core team, an active open-source contributor, and author of The Rust Programming Language, Rails 4 in Action, and Designing Hypermedia APIs books. In 2012 and 2016, we invited Steve to speak at the RailsClub (now RubyRussia) conference. Since then, Steve has been working on Rust a lot, did a lot of interesting things and we realized that we should definitely interview him once again!

Prevent Breaking Code Changes in Future Releases using `non exhaustive` enums in Rust

Hello everyone, recently I have come across a feature in Rust, known as non_exhaustive. It was introduced in Rust 1.40.0 . This attribute prevents source code-breaking changes in projects downstream.

Rust vs Go - Which Is More Popular?

Rust vs Go - Which Is More Popular - Go and Rust are two of the hottest compiled programming languages. I develop in Go full-time and love it, and I'm learning more about Rust recently - its an exc