diff --git a/src/client/http_client.rs b/src/client/http_client.rs index 5478e69f..fd50ef01 100644 --- a/src/client/http_client.rs +++ b/src/client/http_client.rs @@ -497,55 +497,55 @@ impl BackupReader { Arc::new(Self { h2, canceller: canceller }) } - pub fn get( + pub async fn get( &self, path: &str, param: Option, - ) -> impl Future> { - self.h2.get(path, param) + ) -> Result { + self.h2.get(path, param).await } - pub fn put( + pub async fn put( &self, path: &str, param: Option, - ) -> impl Future> { - self.h2.put(path, param) + ) -> Result { + self.h2.put(path, param).await } - pub fn post( + pub async fn post( &self, path: &str, param: Option, - ) -> impl Future> { - self.h2.post(path, param) + ) -> Result { + self.h2.post(path, param).await } - pub fn download( + pub async fn download( &self, file_name: &str, output: W, - ) -> impl Future> { + ) -> Result { let path = "download"; let param = json!({ "file-name": file_name }); - self.h2.download(path, Some(param), output) + self.h2.download(path, Some(param), output).await } - pub fn speedtest( + pub async fn speedtest( &self, output: W, - ) -> impl Future> { - self.h2.download("speedtest", None, output) + ) -> Result { + self.h2.download("speedtest", None, output).await } - pub fn download_chunk( + pub async fn download_chunk( &self, digest: &[u8; 32], output: W, - ) -> impl Future> { + ) -> Result { let path = "chunk"; let param = json!({ "digest": digest_to_hex(digest) }); - self.h2.download(path, Some(param), output) + self.h2.download(path, Some(param), output).await } pub fn force_close(self) { @@ -1105,12 +1105,12 @@ impl H2Client { self.request(req) } - pub fn download( + pub async fn download( &self, path: &str, param: Option, output: W, - ) -> impl Future> { + ) -> Result { let request = Self::request_builder("localhost", "GET", path, param).unwrap(); self.send_request(request, None) @@ -1143,6 +1143,7 @@ impl H2Client { } }) }) + .await } pub fn upload(