Rust Async Libraries Cheat Sheet for Node.js Developers

Written by grantminer | Published 2017/01/05
Tech Story Tags: rust | nodejs

TLDRvia the TL;DR App

Mio is a bit like libuv and libev before that. It’s a lightweight IO library over the OS abstractions.

Futures are basically the same as promises. Java and C# also call them Futures. The futures library also provides streams, which are similar to Node streams but more strongly typed. Streams are to futures as arrays are to values. Streams can even be viewed as a Future using into_future, where the resolved value is the next item in the stream along with the rest of the stream. This seems like a really neat feature.

Tokio-core depends on / is built on top of Futures and Mio. This library provides the I/O primitives and event loop for async I/O in Rust. It’s the connection between futures and mio. For example, connecting a TCP stream returns a Future resolving to a TCP stream, and a TCP listener implements a stream of TCP streams (accepted connections).

Reactor::Core is an instance of an event loop (like that of which you get implicitly in JavaScript). Reactor seems to be a commonly used name for an event loop type object.

Timeout is like setTimeout and interval is like setInterval.

Those are the basics, so the examples should be fairly self-explanatory. Here is another good read on Tokio.

a fast base64 encoder and decoder.

Hacker Noon is how hackers start their afternoons. We’re a part of the @AMIfamily. We are now accepting submissions and happy to discuss advertising &sponsorship opportunities.

To learn more, read our about page, like/message us on Facebook, or simply, tweet/DM @HackerNoon.

If you enjoyed this story, we recommend reading our latest tech stories and trending tech stories. Until next time, don’t take the realities of the world for granted!


Published by HackerNoon on 2017/01/05