Migration from GitHub
This commit is contained in:
1182
waytoodeep/Cargo.lock
generated
Normal file
1182
waytoodeep/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
14
waytoodeep/Cargo.toml
Normal file
14
waytoodeep/Cargo.toml
Normal file
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "waytoodeep"
|
||||
version = "0.1.0"
|
||||
authors = ["rarmknecht <rarmknecht@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
color-eyre = "0.5.11"
|
||||
reqwest = { version = "0.11.4", features = ["rustls-tls"], default-features = false }
|
||||
tokio = { version = "1.9.0", features = ["full"] }
|
||||
tracing = "0.1.26"
|
||||
tracing-subscriber = "0.2.19"
|
||||
54
waytoodeep/src/main.rs
Normal file
54
waytoodeep/src/main.rs
Normal file
@@ -0,0 +1,54 @@
|
||||
// Understanding Rust Futures: Way Too Deep
|
||||
// https://fasterthanli.me/articles/understanding-rust-futures-by-going-way-too-deep
|
||||
//
|
||||
|
||||
// Began: 2021 Jul 26
|
||||
// Completed:
|
||||
|
||||
use color_eyre::Report;
|
||||
use tracing::info;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
use reqwest::Client;
|
||||
|
||||
pub const URL_1: &str = "https://fasterthanli.me/articles/whats-in-the-box";
|
||||
pub const URL_2: &str = "https://fasterthanli.me/series/advent-of-code-2020/part-13";
|
||||
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Report> {
|
||||
setup()?;
|
||||
|
||||
info!("Hello from a comfy nest we've made ourselves!");
|
||||
|
||||
let client = Client::new();
|
||||
//let url = "https://fasterthanli.me";
|
||||
//let res = client.get(url).send().await?.error_for_status()?;
|
||||
//info!(%url, content_type = ?res.headers().get("content-type"), "Got a response!");
|
||||
|
||||
fetch_thing(&client, URL_1).await?;
|
||||
fetch_thing(&client, URL_2).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn setup() -> Result<(), Report> {
|
||||
if std::env::var("RUST_LIB_BACKTRACE").is_err() {
|
||||
std::env::set_var("RUST_LIB_BACKTRACE", "1")
|
||||
}
|
||||
color_eyre::install()?;
|
||||
|
||||
if std::env::var("RUST_LOG").is_err() {
|
||||
std::env::set_var("RUST_LOG", "info")
|
||||
}
|
||||
tracing_subscriber::fmt::fmt()
|
||||
.with_env_filter(EnvFilter::from_default_env())
|
||||
.init();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn fetch_thing(client: &Client, url: &str) -> Result<(), Report> {
|
||||
let res = client.get(url).send().await?.error_for_status()?;
|
||||
info!(%url, content_type = ?res.headers().get("content-type"), "Got a response!");
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user