Rust Live Coding: HTTP CLI with Reqwest, Tokio, Async (no talking)

preview_player
Показать описание
Live coding of an HTTP CLI utility similar to curl in #rust. I've gone ahead and used the reqwest library, clap for the command line argument parsing, tokio for the async runtime and println! formatting for printing out various responses/requests..etc. I use the env! macro to read an environment variable and the built-in environment variables for CARGO_PKG_ to read out the version and name information. I'm also using a jsonplaceholder api to help demonstrate how to hit a simple json api. I later found out that by using cargo expand on this cli I could see how that #[tokio::main] works by building a multithreaded blocking function.

I also use a few commands in coc-rust-analyzer to view docs and refresh my workspace - this turns out handy when I want to go right to the docs in the browser.

Cheers! 🍻

🦀 #rust #livecoding #programming
Рекомендации по теме