From 15917726d79cc8042737270adcea61e5485c28a9 Mon Sep 17 00:00:00 2001 From: "Wyatt J. Miller" Date: Sun, 20 Dec 2020 14:24:24 -0500 Subject: [PATCH] updated reqwest create, added async features --- Cargo.toml | 7 +++++-- src/config.rs | 5 +++-- src/request.rs | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6320e98..7cb9542 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ authors = ["Wyatt J. Miller "] edition = "2018" name = "bleak" -version = "0.3.0" +version = "0.3.1" [dependencies] chrono = "0.4.11" @@ -15,12 +15,15 @@ serde_json = "1.0.53" smart-leds = "0.3.0" ws2812-spi = "0.3.0" +[dependencies.async-std] +version = "*" + [dependencies.rppal] features = ["hal"] version = "0.11.3" [dependencies.reqwest] -version = "0.9.24" +version = "0.10.9" [dependencies.openssl] features = ["vendored"] diff --git a/src/config.rs b/src/config.rs index 8d40f58..a5e7fae 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,3 +1,4 @@ +use async_std::{prelude::*, task}; use std::fs::File; use std::io::Read; use std::path::Path; @@ -38,7 +39,7 @@ impl Configuration { port = self.port ); - let response = request::get_request(&request); + let response = task::block_on(request::get_request(&request)); match response { Ok(res) => { @@ -61,7 +62,7 @@ impl Configuration { port = self.port ); - let response = request::get_request(&request); + let response = task::block_on(request::get_request(&request)); match response { Ok(res) => { let document = Document::from_read(res) diff --git a/src/request.rs b/src/request.rs index 405f629..df08cf4 100644 --- a/src/request.rs +++ b/src/request.rs @@ -1,4 +1,6 @@ -pub fn get_request(request: &String) -> Result { - let response = reqwest::get(request); +use async_std::{prelude::*, io}; + +pub async fn get_request(request: &String) -> io::Result { + let response = reqwest::get(request).await?; response } \ No newline at end of file