When to use Tokio?

I see Tokio dependency everywhere, when Rust already support async features.

The main question is, why use Tokio?
Is it high level API for async operations or just some legacy option

Rust std library doesn't have a runtime, or executor, which is needed for using async. You have to choose a runtime in an external crate. Tokio is the most popular of those crates, but there are many others.

See https://rust-lang.github.io/async-book/part-guide/async-await.html#the-runtime

3 Likes

Also, tokio provides a lot of things on top of just the runtime, it has an async version of varios std modules, and an echosystem providing other tools such as hyper, tower and axum (a full fledged webserver). Its not legacy and you see it everywhere because it has most of the things you might need ready to go.

3 Likes