An async runtime manages background tasks and their progress, using threads or other mechanisms. In a web server, this helps work continue while the server accepts further requests. section 1.3
In Rust, an async runtime is compiled into static code. Libraries and frameworks choose which runtime to build on, so an application can include more than one. For example, a web framework may use Tokio while an HTTP helper uses another runtime. Any side effects depend on the application’s design. section 1.3
Listing 1.12 Sending HTTP GET requests asynchronously in Rust
// ch_01/minimal_reqwest/src/main.rs
// https:/ /github.com/Rust-Web-Development/code/tree/main/ch_01/minimal_reqwest
use std::collections::HashMap;
#[tokio::main] #1
async fn main() -> Result<(), Box<dyn std::error::Error>> { #2
let resp = reqwest::get("https:/ /httpbin.org/ip") #3
.await?; #4
.json::<HashMap<String, String>>()
.await?;
println!("{:#?}", resp); #5
Ok(()) #6
}
This asynchronous HTTP request uses Tokio for the runtime and Reqwest to fetch and decode a response. section 1.3


