summaryrefslogtreecommitdiffhomepage
path: root/mullvad-rpc/src/lib.rs
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2020-09-08 09:47:10 +0200
committerDavid Lönnhager <david.l@mullvad.net>2020-09-08 09:47:10 +0200
commit8a76e509ec0abda73e40c6e5563d80098580bc14 (patch)
treefb3a1162dca265877fee3301bf4cb2bb9ac671d9 /mullvad-rpc/src/lib.rs
parent3923c6320152e12b01b52cbff9408a0bb80e057a (diff)
parent9f05c347a9d07911ffa4643f2f50cace0c331500 (diff)
downloadmullvadvpn-8a76e509ec0abda73e40c6e5563d80098580bc14.tar.xz
mullvadvpn-8a76e509ec0abda73e40c6e5563d80098580bc14.zip
Merge branch 'fix-problem-report-tool'
Diffstat (limited to 'mullvad-rpc/src/lib.rs')
-rw-r--r--mullvad-rpc/src/lib.rs33
1 files changed, 14 insertions, 19 deletions
diff --git a/mullvad-rpc/src/lib.rs b/mullvad-rpc/src/lib.rs
index 5e2e6f80fa..60e39f571e 100644
--- a/mullvad-rpc/src/lib.rs
+++ b/mullvad-rpc/src/lib.rs
@@ -1,7 +1,6 @@
#![deny(rust_2018_idioms)]
use chrono::{offset::Utc, DateTime};
-use futures01::future::Future as Future01;
use hyper::Method;
use mullvad_types::{
account::{AccountToken, VoucherSubmission},
@@ -126,7 +125,7 @@ impl AccountsProxy {
pub fn get_expiry(
&self,
account: AccountToken,
- ) -> impl Future01<Item = DateTime<Utc>, Error = rest::Error> {
+ ) -> impl Future<Output = Result<DateTime<Utc>, rest::Error>> {
let service = self.handle.service.clone();
let response = rest::send_request(
@@ -137,13 +136,13 @@ impl AccountsProxy {
Some(account),
StatusCode::OK,
);
- self.handle.service.compat_spawn(async move {
+ async move {
let account: AccountResponse = rest::deserialize_body(response.await?).await?;
Ok(account.expires)
- })
+ }
}
- pub fn create_account(&mut self) -> impl Future01<Item = AccountToken, Error = rest::Error> {
+ pub fn create_account(&mut self) -> impl Future<Output = Result<AccountToken, rest::Error>> {
let service = self.handle.service.clone();
let response = rest::send_request(
&self.handle.factory,
@@ -154,17 +153,17 @@ impl AccountsProxy {
StatusCode::CREATED,
);
- self.handle.service.compat_spawn(async move {
+ async move {
let account: AccountResponse = rest::deserialize_body(response.await?).await?;
Ok(account.token)
- })
+ }
}
pub fn submit_voucher(
&mut self,
account_token: AccountToken,
voucher_code: String,
- ) -> impl Future01<Item = VoucherSubmission, Error = rest::Error> {
+ ) -> impl Future<Output = Result<VoucherSubmission, rest::Error>> {
#[derive(serde::Serialize)]
struct VoucherSubmission {
voucher_code: String,
@@ -182,15 +181,13 @@ impl AccountsProxy {
StatusCode::OK,
);
- self.handle
- .service
- .compat_spawn(async move { rest::deserialize_body(response.await?).await })
+ async move { rest::deserialize_body(response.await?).await }
}
pub fn get_www_auth_token(
&self,
account: AccountToken,
- ) -> impl Future01<Item = String, Error = rest::Error> {
+ ) -> impl Future<Output = Result<String, rest::Error>> {
#[derive(serde::Deserialize)]
struct AuthTokenResponse {
auth_token: String,
@@ -206,12 +203,10 @@ impl AccountsProxy {
StatusCode::OK,
);
- let future = async move {
+ async move {
let response: AuthTokenResponse = rest::deserialize_body(response.await?).await?;
Ok(response.auth_token)
- };
-
- self.handle.service.compat_spawn(future)
+ }
}
}
@@ -230,7 +225,7 @@ impl ProblemReportProxy {
message: &str,
log: &str,
metadata: &BTreeMap<String, String>,
- ) -> impl Future01<Item = (), Error = rest::Error> {
+ ) -> impl Future<Output = Result<(), rest::Error>> {
#[derive(serde::Serialize)]
struct ProblemReport {
address: String,
@@ -257,10 +252,10 @@ impl ProblemReportProxy {
StatusCode::NO_CONTENT,
);
- self.handle.service.compat_spawn(async move {
+ async move {
request.await?;
Ok(())
- })
+ }
}
}