24 days of Rust - reqwest

In the first volume of 24 Days of Rust, I've written about hyper as the Rust HTTP toolkit. A lot of things have changed in the last two years, but hyper is still the best solution for HTTP in Rust. However, hyper is undergoing some major changes to use tokio for async I/O. While this will be fantastic for use cases where performance is top priority, it will also make hyper APIs a bit more complex. It's good to know about event loops, futures and services, but sometimes we just want to send a GET request and call it a day.

Sean McArthur created Reqwest specifically for such scenarios. It is a high level HTTP client built on top of hyper. The situation here is somewhat similar to Python, where requests provides a simple API on top of heavy urllib3 machinery. Reqwest is relatively new compared to requests, but it has the same goal - to make simple HTTP requests easy and delegate complex tasks to hyper.

Reqwest also uses OS-provided TLS support if possible. This avoids a lot of pain setting up OpenSSL on Windows.

Continue reading »
Written on Dec. 20, 2016

24 days of Rust - working with JSON

Important note: this article is outdated! Go to http://zsiciarz.github.io/24daysofrust/ for a recent version of all of 24 days of Rust articles. The blogpost here is kept as it is for historical reasons.

JSON is a workhorse data format of the modern Web. Originating from the JavaScript world, it gained a lot of traction and at the moment it's usually the first choice of a Web developer for a data interchange format. Not only Web - once JavaScript-only, JSON support is now ubiquitous. A lot of languages ship with JSON parsers in the standard libraries, and when it's not the case, surely someone has already built a third party library. In case of Rust, JSON support comes out of the box in the serialize::json module.

Continue reading »
Written on Dec. 6, 2014