Move to reqwest from git (alpha.0) and tokio 0.2.0.alpha.4!

This commit is contained in:
Waffle 2019-09-08 01:44:55 +03:00
parent 1f50a87daf
commit b0d88d69ea
3 changed files with 3 additions and 9 deletions

View file

@ -6,12 +6,11 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
futures-preview = { version = "0.3.0-alpha.14", features = ["compat"] }
reqwest = "0.9.20"
reqwest = { git = "https://github.com/seanmonstar/reqwest", rev = "ba7b2a754eab0d79817ea8551d0803806ae8af7d" }
serde_json = "1.0.39"
serde = {version = "1.0.92", features = ["derive"] }
lazy_static = "1.3"
apply = "0.2.2"
derive_more = "0.15.0"
tokio = "0.1"
tokio = "0.2.0-alpha.4"
bytes = "0.4.12"

View file

@ -1,5 +1,4 @@
use apply::Apply;
use futures::compat::Future01CompatExt;
use reqwest::r#async::{multipart::Form, Client};
use serde::de::DeserializeOwned;
use serde_json::Value;
@ -46,14 +45,12 @@ pub async fn request_multipart<T: DeserializeOwned>(
None => request_builder,
})
.send()
.compat()
.await
.map_err(RequestError::NetworkError)?;
let response_json = serde_json::from_str::<Value>(
&response
.text()
.compat()
.await
.map_err(RequestError::NetworkError)?,
)
@ -79,14 +76,12 @@ pub async fn request_json<T: DeserializeOwned, P: Serialize>(
.post(&method_url(TELEGRAM_API_URL, token, method_name))
.json(params)
.send()
.compat()
.await
.map_err(RequestError::NetworkError)?;
let response_json = serde_json::from_str::<Value>(
&response
.text()
.compat()
.await
.map_err(RequestError::NetworkError)?,
)

View file

@ -21,7 +21,7 @@ impl tokio::codec::Decoder for FileDecoder {
pub fn file_to_part(path_to_file: &PathBuf) -> Part {
let file = tokio::fs::File::open(path_to_file.clone())
.map(|file| FramedRead::new(file, FileDecoder))
.map(|file| FramedRead::new(file.unwrap() /* TODO: this can cause panics */, FileDecoder))
.flatten_stream();
let part = Part::stream(file)
.file_name(path_to_file.file_name().unwrap().to_string_lossy().into_owned());