Skip to content

Instantly share code, notes, and snippets.

@sodiumjoe
Last active September 4, 2018 04:55
Show Gist options
  • Save sodiumjoe/528ebb0fd2d170604032c39df9df9559 to your computer and use it in GitHub Desktop.
Save sodiumjoe/528ebb0fd2d170604032c39df9df9559 to your computer and use it in GitHub Desktop.
pub fn fetch(self) -> impl Future<Item = Data, Error = Error> {
let req = Request::get(self.uri)
.body(Body::empty())
.unwrap();
let https = HttpsConnector::new(4).expect("tls initialization error");
let client = Client::builder().build::<_, Body>(https);
client
.request(req)
.map(|res| res.into_body())
.and_then(|body: Body| body.concat2())
.then(|body| {
let body: Vec<u8> = body?;
let json = serde_json::from_slice(&body)?;
Ok(json)
})
.from_err::<Error>()
}
/*
error[E0282]: type annotations needed
--> src/mercury.rs:50:28
|
50 | let body = body?;
| ^^^^^ cannot infer type for `_`
error: aborting due to previous error
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment