Last active
September 4, 2018 04:55
-
-
Save sodiumjoe/528ebb0fd2d170604032c39df9df9559 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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