From 2194824f77008d8c307943c6bab6267ca93753f8 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 21 Nov 2019 14:16:37 +0100 Subject: [PATCH] api: BoxFut -> ApiFuture Signed-off-by: Wolfgang Bumiller --- src/api2/admin/datastore.rs | 4 ++-- src/api2/backup.rs | 6 +++--- src/api2/backup/upload_chunk.rs | 8 ++++---- src/api2/reader.rs | 10 +++++----- src/api_schema.rs | 4 +--- src/server/rest.rs | 10 +++++----- 6 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index aa672009..17e65cd2 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -481,7 +481,7 @@ fn download_file( param: Value, _info: &ApiMethod, _rpcenv: Box, -) -> Result { +) -> Result { let store = tools::required_string_param(¶m, "store")?; @@ -544,7 +544,7 @@ fn upload_backup_log( param: Value, _info: &ApiMethod, _rpcenv: Box, -) -> Result { +) -> Result { let store = tools::required_string_param(¶m, "store")?; diff --git a/src/api2/backup.rs b/src/api2/backup.rs index a803a3a4..e3cfd230 100644 --- a/src/api2/backup.rs +++ b/src/api2/backup.rs @@ -47,7 +47,7 @@ fn upgrade_to_backup_protocol( param: Value, _info: &ApiMethod, rpcenv: Box, -) -> Result { +) -> Result { let debug = param["debug"].as_bool().unwrap_or(false); @@ -569,7 +569,7 @@ fn dynamic_chunk_index( param: Value, _info: &ApiMethod, rpcenv: Box, -) -> Result { +) -> Result { let env: &BackupEnvironment = rpcenv.as_ref(); @@ -642,7 +642,7 @@ fn fixed_chunk_index( param: Value, _info: &ApiMethod, rpcenv: Box, -) -> Result { +) -> Result { let env: &BackupEnvironment = rpcenv.as_ref(); diff --git a/src/api2/backup/upload_chunk.rs b/src/api2/backup/upload_chunk.rs index de3512fa..80125d05 100644 --- a/src/api2/backup/upload_chunk.rs +++ b/src/api2/backup/upload_chunk.rs @@ -115,7 +115,7 @@ fn upload_fixed_chunk( param: Value, _info: &ApiMethod, rpcenv: Box, -) -> Result { +) -> Result { let wid = tools::required_integer_param(¶m, "wid")? as usize; let size = tools::required_integer_param(¶m, "size")? as u32; @@ -177,7 +177,7 @@ fn upload_dynamic_chunk( param: Value, _info: &ApiMethod, rpcenv: Box, -) -> Result { +) -> Result { let wid = tools::required_integer_param(¶m, "wid")? as usize; let size = tools::required_integer_param(¶m, "size")? as u32; @@ -218,7 +218,7 @@ fn upload_speedtest( _param: Value, _info: &ApiMethod, rpcenv: Box, -) -> Result { +) -> Result { let resp = req_body .map_err(Error::from) @@ -265,7 +265,7 @@ fn upload_blob( param: Value, _info: &ApiMethod, rpcenv: Box, -) -> Result { +) -> Result { let file_name = tools::required_string_param(¶m, "file-name")?.to_owned(); let encoded_size = tools::required_integer_param(¶m, "encoded-size")? as usize; diff --git a/src/api2/reader.rs b/src/api2/reader.rs index b5f4cfb0..f809a51f 100644 --- a/src/api2/reader.rs +++ b/src/api2/reader.rs @@ -50,7 +50,7 @@ fn upgrade_to_backup_reader_protocol( param: Value, _info: &ApiMethod, rpcenv: Box, -) -> Result { +) -> Result { let debug = param["debug"].as_bool().unwrap_or(false); @@ -171,7 +171,7 @@ fn download_file( param: Value, _info: &ApiMethod, rpcenv: Box, -) -> Result { +) -> Result { let env: &ReaderEnvironment = rpcenv.as_ref(); let env2 = env.clone(); @@ -222,7 +222,7 @@ fn download_chunk( param: Value, _info: &ApiMethod, rpcenv: Box, -) -> Result { +) -> Result { let env: &ReaderEnvironment = rpcenv.as_ref(); @@ -258,7 +258,7 @@ fn download_chunk_old( param: Value, _info: &ApiMethod, rpcenv: Box, -) -> Result { +) -> Result { let env: &ReaderEnvironment = rpcenv.as_ref(); let env2 = env.clone(); @@ -303,7 +303,7 @@ fn speedtest( _param: Value, _info: &ApiMethod, _rpcenv: Box, -) -> Result { +) -> Result { let buffer = vec![65u8; 1024*1024]; // nonsense [A,A,A...] diff --git a/src/api_schema.rs b/src/api_schema.rs index a35cf1e3..40fca497 100644 --- a/src/api_schema.rs +++ b/src/api_schema.rs @@ -22,10 +22,8 @@ pub mod format; pub use proxmox::api::schema::*; pub use proxmox::api::*; -pub use proxmox::api::ApiFuture as BoxFut; - pub mod api_handler { - pub use super::{ApiAsyncHandlerFn, ApiHandler, ApiHandlerFn, BoxFut}; + pub use super::{ApiAsyncHandlerFn, ApiHandler, ApiHandlerFn, ApiFuture}; } pub mod router { diff --git a/src/server/rest.rs b/src/server/rest.rs index 707d59bb..f85ba398 100644 --- a/src/server/rest.rs +++ b/src/server/rest.rs @@ -229,7 +229,7 @@ fn proxy_protected_request( info: &'static ApiMethod, mut parts: Parts, req_body: Body, -) -> BoxFut { +) -> ApiFuture { let mut uri_parts = parts.uri.clone().into_parts(); @@ -269,7 +269,7 @@ pub fn handle_sync_api_request, -) -> BoxFut +) -> ApiFuture { let handler = match info.handler { ApiHandler::Async(_) => { @@ -322,7 +322,7 @@ pub fn handle_async_api_request( parts: Parts, req_body: Body, uri_param: HashMap, -) -> BoxFut +) -> ApiFuture { let handler = match info.handler { ApiHandler::Sync(_) => { @@ -489,7 +489,7 @@ async fn chuncked_static_file_download(filename: PathBuf) -> Result BoxFut { +fn handle_static_file_download(filename: PathBuf) -> ApiFuture { let response = tokio::fs::metadata(filename.clone()) .map_err(|err| http_err!(BAD_REQUEST, format!("File access problems: {}", err))) @@ -554,7 +554,7 @@ async fn delayed_response( Ok(resp) } -pub fn handle_request(api: Arc, req: Request) -> BoxFut { +pub fn handle_request(api: Arc, req: Request) -> ApiFuture { let (parts, body) = req.into_parts();