api: BoxFut -> ApiFuture

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-11-21 14:16:37 +01:00
parent 3d482025b3
commit 2194824f77
6 changed files with 20 additions and 22 deletions

View File

@ -481,7 +481,7 @@ fn download_file(
param: Value, param: Value,
_info: &ApiMethod, _info: &ApiMethod,
_rpcenv: Box<dyn RpcEnvironment>, _rpcenv: Box<dyn RpcEnvironment>,
) -> Result<BoxFut, Error> { ) -> Result<ApiFuture, Error> {
let store = tools::required_string_param(&param, "store")?; let store = tools::required_string_param(&param, "store")?;
@ -544,7 +544,7 @@ fn upload_backup_log(
param: Value, param: Value,
_info: &ApiMethod, _info: &ApiMethod,
_rpcenv: Box<dyn RpcEnvironment>, _rpcenv: Box<dyn RpcEnvironment>,
) -> Result<BoxFut, Error> { ) -> Result<ApiFuture, Error> {
let store = tools::required_string_param(&param, "store")?; let store = tools::required_string_param(&param, "store")?;

View File

@ -47,7 +47,7 @@ fn upgrade_to_backup_protocol(
param: Value, param: Value,
_info: &ApiMethod, _info: &ApiMethod,
rpcenv: Box<dyn RpcEnvironment>, rpcenv: Box<dyn RpcEnvironment>,
) -> Result<BoxFut, Error> { ) -> Result<ApiFuture, Error> {
let debug = param["debug"].as_bool().unwrap_or(false); let debug = param["debug"].as_bool().unwrap_or(false);
@ -569,7 +569,7 @@ fn dynamic_chunk_index(
param: Value, param: Value,
_info: &ApiMethod, _info: &ApiMethod,
rpcenv: Box<dyn RpcEnvironment>, rpcenv: Box<dyn RpcEnvironment>,
) -> Result<BoxFut, Error> { ) -> Result<ApiFuture, Error> {
let env: &BackupEnvironment = rpcenv.as_ref(); let env: &BackupEnvironment = rpcenv.as_ref();
@ -642,7 +642,7 @@ fn fixed_chunk_index(
param: Value, param: Value,
_info: &ApiMethod, _info: &ApiMethod,
rpcenv: Box<dyn RpcEnvironment>, rpcenv: Box<dyn RpcEnvironment>,
) -> Result<BoxFut, Error> { ) -> Result<ApiFuture, Error> {
let env: &BackupEnvironment = rpcenv.as_ref(); let env: &BackupEnvironment = rpcenv.as_ref();

View File

@ -115,7 +115,7 @@ fn upload_fixed_chunk(
param: Value, param: Value,
_info: &ApiMethod, _info: &ApiMethod,
rpcenv: Box<dyn RpcEnvironment>, rpcenv: Box<dyn RpcEnvironment>,
) -> Result<BoxFut, Error> { ) -> Result<ApiFuture, Error> {
let wid = tools::required_integer_param(&param, "wid")? as usize; let wid = tools::required_integer_param(&param, "wid")? as usize;
let size = tools::required_integer_param(&param, "size")? as u32; let size = tools::required_integer_param(&param, "size")? as u32;
@ -177,7 +177,7 @@ fn upload_dynamic_chunk(
param: Value, param: Value,
_info: &ApiMethod, _info: &ApiMethod,
rpcenv: Box<dyn RpcEnvironment>, rpcenv: Box<dyn RpcEnvironment>,
) -> Result<BoxFut, Error> { ) -> Result<ApiFuture, Error> {
let wid = tools::required_integer_param(&param, "wid")? as usize; let wid = tools::required_integer_param(&param, "wid")? as usize;
let size = tools::required_integer_param(&param, "size")? as u32; let size = tools::required_integer_param(&param, "size")? as u32;
@ -218,7 +218,7 @@ fn upload_speedtest(
_param: Value, _param: Value,
_info: &ApiMethod, _info: &ApiMethod,
rpcenv: Box<dyn RpcEnvironment>, rpcenv: Box<dyn RpcEnvironment>,
) -> Result<BoxFut, Error> { ) -> Result<ApiFuture, Error> {
let resp = req_body let resp = req_body
.map_err(Error::from) .map_err(Error::from)
@ -265,7 +265,7 @@ fn upload_blob(
param: Value, param: Value,
_info: &ApiMethod, _info: &ApiMethod,
rpcenv: Box<dyn RpcEnvironment>, rpcenv: Box<dyn RpcEnvironment>,
) -> Result<BoxFut, Error> { ) -> Result<ApiFuture, Error> {
let file_name = tools::required_string_param(&param, "file-name")?.to_owned(); let file_name = tools::required_string_param(&param, "file-name")?.to_owned();
let encoded_size = tools::required_integer_param(&param, "encoded-size")? as usize; let encoded_size = tools::required_integer_param(&param, "encoded-size")? as usize;

View File

@ -50,7 +50,7 @@ fn upgrade_to_backup_reader_protocol(
param: Value, param: Value,
_info: &ApiMethod, _info: &ApiMethod,
rpcenv: Box<dyn RpcEnvironment>, rpcenv: Box<dyn RpcEnvironment>,
) -> Result<BoxFut, Error> { ) -> Result<ApiFuture, Error> {
let debug = param["debug"].as_bool().unwrap_or(false); let debug = param["debug"].as_bool().unwrap_or(false);
@ -171,7 +171,7 @@ fn download_file(
param: Value, param: Value,
_info: &ApiMethod, _info: &ApiMethod,
rpcenv: Box<dyn RpcEnvironment>, rpcenv: Box<dyn RpcEnvironment>,
) -> Result<BoxFut, Error> { ) -> Result<ApiFuture, Error> {
let env: &ReaderEnvironment = rpcenv.as_ref(); let env: &ReaderEnvironment = rpcenv.as_ref();
let env2 = env.clone(); let env2 = env.clone();
@ -222,7 +222,7 @@ fn download_chunk(
param: Value, param: Value,
_info: &ApiMethod, _info: &ApiMethod,
rpcenv: Box<dyn RpcEnvironment>, rpcenv: Box<dyn RpcEnvironment>,
) -> Result<BoxFut, Error> { ) -> Result<ApiFuture, Error> {
let env: &ReaderEnvironment = rpcenv.as_ref(); let env: &ReaderEnvironment = rpcenv.as_ref();
@ -258,7 +258,7 @@ fn download_chunk_old(
param: Value, param: Value,
_info: &ApiMethod, _info: &ApiMethod,
rpcenv: Box<dyn RpcEnvironment>, rpcenv: Box<dyn RpcEnvironment>,
) -> Result<BoxFut, Error> { ) -> Result<ApiFuture, Error> {
let env: &ReaderEnvironment = rpcenv.as_ref(); let env: &ReaderEnvironment = rpcenv.as_ref();
let env2 = env.clone(); let env2 = env.clone();
@ -303,7 +303,7 @@ fn speedtest(
_param: Value, _param: Value,
_info: &ApiMethod, _info: &ApiMethod,
_rpcenv: Box<dyn RpcEnvironment>, _rpcenv: Box<dyn RpcEnvironment>,
) -> Result<BoxFut, Error> { ) -> Result<ApiFuture, Error> {
let buffer = vec![65u8; 1024*1024]; // nonsense [A,A,A...] let buffer = vec![65u8; 1024*1024]; // nonsense [A,A,A...]

View File

@ -22,10 +22,8 @@ pub mod format;
pub use proxmox::api::schema::*; pub use proxmox::api::schema::*;
pub use proxmox::api::*; pub use proxmox::api::*;
pub use proxmox::api::ApiFuture as BoxFut;
pub mod api_handler { pub mod api_handler {
pub use super::{ApiAsyncHandlerFn, ApiHandler, ApiHandlerFn, BoxFut}; pub use super::{ApiAsyncHandlerFn, ApiHandler, ApiHandlerFn, ApiFuture};
} }
pub mod router { pub mod router {

View File

@ -229,7 +229,7 @@ fn proxy_protected_request(
info: &'static ApiMethod, info: &'static ApiMethod,
mut parts: Parts, mut parts: Parts,
req_body: Body, req_body: Body,
) -> BoxFut { ) -> ApiFuture {
let mut uri_parts = parts.uri.clone().into_parts(); let mut uri_parts = parts.uri.clone().into_parts();
@ -269,7 +269,7 @@ pub fn handle_sync_api_request<Env: RpcEnvironment, S: 'static + BuildHasher + S
parts: Parts, parts: Parts,
req_body: Body, req_body: Body,
uri_param: HashMap<String, String, S>, uri_param: HashMap<String, String, S>,
) -> BoxFut ) -> ApiFuture
{ {
let handler = match info.handler { let handler = match info.handler {
ApiHandler::Async(_) => { ApiHandler::Async(_) => {
@ -322,7 +322,7 @@ pub fn handle_async_api_request<Env: RpcEnvironment>(
parts: Parts, parts: Parts,
req_body: Body, req_body: Body,
uri_param: HashMap<String, String>, uri_param: HashMap<String, String>,
) -> BoxFut ) -> ApiFuture
{ {
let handler = match info.handler { let handler = match info.handler {
ApiHandler::Sync(_) => { ApiHandler::Sync(_) => {
@ -489,7 +489,7 @@ async fn chuncked_static_file_download(filename: PathBuf) -> Result<Response<Bod
) )
} }
fn handle_static_file_download(filename: PathBuf) -> BoxFut { fn handle_static_file_download(filename: PathBuf) -> ApiFuture {
let response = tokio::fs::metadata(filename.clone()) let response = tokio::fs::metadata(filename.clone())
.map_err(|err| http_err!(BAD_REQUEST, format!("File access problems: {}", err))) .map_err(|err| http_err!(BAD_REQUEST, format!("File access problems: {}", err)))
@ -554,7 +554,7 @@ async fn delayed_response(
Ok(resp) Ok(resp)
} }
pub fn handle_request(api: Arc<ApiConfig>, req: Request<Body>) -> BoxFut { pub fn handle_request(api: Arc<ApiConfig>, req: Request<Body>) -> ApiFuture {
let (parts, body) = req.into_parts(); let (parts, body) = req.into_parts();