From b0d88d69eab4df3ed66e1845e6164a645e0e205e Mon Sep 17 00:00:00 2001 From: Waffle Date: Sun, 8 Sep 2019 01:44:55 +0300 Subject: [PATCH] Move to reqwest from git (`alpha.0`) and tokio `0.2.0.alpha.4`! --- Cargo.toml | 5 ++--- src/core/network/mod.rs | 5 ----- src/core/requests/utils.rs | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fba1a67f..d4c2b459 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" \ No newline at end of file diff --git a/src/core/network/mod.rs b/src/core/network/mod.rs index e331fc0d..b2fd4d08 100644 --- a/src/core/network/mod.rs +++ b/src/core/network/mod.rs @@ -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( None => request_builder, }) .send() - .compat() .await .map_err(RequestError::NetworkError)?; let response_json = serde_json::from_str::( &response .text() - .compat() .await .map_err(RequestError::NetworkError)?, ) @@ -79,14 +76,12 @@ pub async fn request_json( .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::( &response .text() - .compat() .await .map_err(RequestError::NetworkError)?, ) diff --git a/src/core/requests/utils.rs b/src/core/requests/utils.rs index 4368df79..292d9981 100644 --- a/src/core/requests/utils.rs +++ b/src/core/requests/utils.rs @@ -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());