This example is part of a larger repository of examples, async-applied.
reqwest is an excellent crate for making HTTP requests in the vein of wget, curl, etc. tokio is the de facto Rust async runtime, especially for io-driven tasks. This example demonstrates the simplest possible use of these two crates together to download a picture of the Rust mascot, Ferris.
If you have done much reading in the tokio documentation you may wonder why we use a while let
loop to drive the download in "chunks" rather than calling tokio::io::copy
? The answer is in the reqwest-tokio-compat example.