Согласно этому примеру, я должен можно запустить get
на клиенте, созданном с помощью построителя клиентов:
use reqwest::header;
let mut headers = header::Headers::new();
headers.set(header::Authorization("secret".to_string()));
// get a client builder
let client = reqwest::Client::builder()
.default_headers(headers)
.build()?;
let res = client.get("https://www.rust-lang.org").send()?;
Ниже приведен код, который я написал.
let client = Client::builder()
.gzip(true)
.timeout(Duration::from_secs(10))
.build();
let resp = client.get("https://wiki.mozilla.org/images/f/ff/Example.json.gz");
Это ошибка, которую я получаю:
error[E0599]: no method named `get` found for type `std::result::Result<reqwest::Client, reqwest::Error>` in the current scope
--> examples/gzipped_http_files.rs:86:23
|
86 | let resp = client.get("https://wiki.mozilla.org/images/f/ff/Example.json.gz");
Что я делаю не так?
.build()
. Обратите внимание на оператор?
в исходном примере. - person E_net4 the curator   schedule 07.02.2019.build().expect("Could not build the client")
и т. д. - person Shepmaster   schedule 07.02.2019