O'Reilly logo

Network Programming with Rust by Abhishek Chanda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Introducing Hyper

Hyper is arguably the most stable and well-known of Rust-based HTTP frameworks. It has two distinct components, one for writing HTTP servers and one for writing clients. Recently, the server component was moved to a new async programming model based on tokio and futures. As a result, it is well-suited for high-traffic workloads. However, like a lot of other libraries in the ecosystem, Hyper has not hit Version 1.0 yet, so one should expect breaking API changes.

We will start with writing a small HTTP server in Hyper. Like always, we will need to set up our project using Cargo.

$ cargo new --bin hyper-server

Let us now add dependencies that will include hyper and futures. The Cargo.toml file will look as follows:

[package] ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required