reqwest

The trait `std::future::Future` is not implemented for `std::result::Result<reqwest::Response, reqwest::Error>`

我怕爱的太早我们不能终老 提交于 2020-05-29 09:41:20
问题 I'm trying to run basic reqwest example: extern crate reqwest; extern crate tokio; #[tokio::main] async fn main() -> Result<(), reqwest::Error> { let res = reqwest::Client::new() .get("https://hyper.rs") .send() .await?; println!("Status: {}", res.status()); let body = res.text().await?; println!("Body:\n\n{}", body); Ok(()) } Error that I'm getting: --> src/main.rs:6:15 | 6 | let res = reqwest::Client::new() | _______________^ 7 | | .get("https://hyper.rs") 8 | | .send() 9 | | .await?; | |__

How can I perform parallel asynchronous HTTP GET requests with reqwest?

☆樱花仙子☆ 提交于 2020-01-10 02:04:12
问题 The async example is useful, but being new to Rust and Tokio, I am struggling to work out how to do N requests at once, using URLs from a vector, and creating an iterator of the response HTML for each URL as a string. How could this be done? 回答1: As of reqwest 0.10: use futures::{stream, StreamExt}; // 0.3.1 use reqwest::Client; // 0.10.0 use tokio; // 0.2.4, features = ["macros"] const PARALLEL_REQUESTS: usize = 2; #[tokio::main] async fn main() { let client = Client::new(); let urls = vec![

How can I perform parallel asynchronous HTTP GET requests with reqwest?

人走茶凉 提交于 2019-11-30 21:17:34
The async example is useful, but being new to Rust and Tokio, I am struggling to work out how to do N requests at once, using URLs from a vector, and creating an iterator of the response HTML for each URL as a string. How could this be done? As of reqwest 0.9: use futures::{stream, Future, Stream}; // 0.1.26 use reqwest::r#async::Client; // 0.9.14 use tokio; // 0.1.18 type Result<T> = std::result::Result<T, Box<std::error::Error>>; const PARALLEL_REQUESTS: usize = 2; fn main() -> Result<()> { let client = Client::new(); let urls = vec!["https://api.ipify.org", "https://api.ipify.org"]; let

Why does a lazy-static value claim to not implement a trait that it clearly implements?

耗尽温柔 提交于 2019-11-28 13:57:11
With the following code (an attempt to make an HTTP request using the reqwest crate), the compiler says that my value SID_URI does not implement the trait PolyfillTryInto . What's going on here? reqwest::Url clearly implements the private trait reqwest::into_url::PolyfillTryInto . #[macro_use] extern crate lazy_static; extern crate reqwest; static R_EMAIL: &str = "example@example.com"; static R_PASS: &str = "password"; static API_PUBKEY: &str = "99754106633f94d350db34d548d6091a"; static API_URI: &str = "https://example.com"; static AUTH_PATH: &str = "/api/v1"; lazy_static! { static ref SID_URI

Why does a lazy-static value claim to not implement a trait that it clearly implements?

ぃ、小莉子 提交于 2019-11-27 07:06:30
问题 With the following code (an attempt to make an HTTP request using the reqwest crate), the compiler says that my value SID_URI does not implement the trait PolyfillTryInto . What's going on here? reqwest::Url clearly implements the private trait reqwest::into_url::PolyfillTryInto. #[macro_use] extern crate lazy_static; extern crate reqwest; static R_EMAIL: &str = "example@example.com"; static R_PASS: &str = "password"; static API_PUBKEY: &str = "99754106633f94d350db34d548d6091a"; static API