In this chapter, we will finally get around to using the reqwest crate. As you read through this chapter, you’ll soon see why we didn’t learn it until now: it’s because the reqwest crate is the first one we have encountered that involves async Rust! Well, sort of. Read on to find out.
While we’re at it, we’ll also learn about feature flags, which let you bring in just part of an external crate and thereby help keep compilation time down.
Back in chapter 17, we had a code sample that included a Client (http://mng.bz/mjv4) from the reqwest crate in one of our structs. We didn’t use it at the time because (among other reasons) the Rust Playground doesn’t allow you to make HTTP requests. The code looked like this:
use reqwest::Client; struct Logger { logs: Vec<Log>, url: String, client: Client, }
use reqwest::Client; fn main() { let client = Client::default(); }