From 329d40b50b4d0d3ab143a8097d3114d85c0f26d8 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Sat, 23 Nov 2019 09:03:21 +0100 Subject: [PATCH] rename ApiHandler::Async into ApiHandler::AsyncHttp --- src/api2/admin/datastore.rs | 4 ++-- src/api2/backup.rs | 6 +++--- src/api2/backup/upload_chunk.rs | 8 ++++---- src/api2/reader.rs | 8 ++++---- src/cli/command.rs | 8 +++++--- src/server/rest.rs | 2 +- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index 137d6b79..b25b76ae 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -521,7 +521,7 @@ fn download_file( #[sortable] pub const API_METHOD_DOWNLOAD_FILE: ApiMethod = ApiMethod::new( - &ApiHandler::Async(&download_file), + &ApiHandler::AsyncHttp(&download_file), &ObjectSchema::new( "Download single raw file from backup snapshot.", &sorted!([ @@ -590,7 +590,7 @@ fn upload_backup_log( #[sortable] pub const API_METHOD_UPLOAD_BACKUP_LOG: ApiMethod = ApiMethod::new( - &ApiHandler::Async(&upload_backup_log), + &ApiHandler::AsyncHttp(&upload_backup_log), &ObjectSchema::new( "Download single raw file from backup snapshot.", &sorted!([ diff --git a/src/api2/backup.rs b/src/api2/backup.rs index bf731153..13463716 100644 --- a/src/api2/backup.rs +++ b/src/api2/backup.rs @@ -28,7 +28,7 @@ pub const ROUTER: Router = Router::new() #[sortable] pub const API_METHOD_UPGRADE_BACKUP: ApiMethod = ApiMethod::new( - &ApiHandler::Async(&upgrade_to_backup_protocol), + &ApiHandler::AsyncHttp(&upgrade_to_backup_protocol), &ObjectSchema::new( concat!("Upgraded to backup protocol ('", PROXMOX_BACKUP_PROTOCOL_ID_V1!(), "')."), &sorted!([ @@ -553,7 +553,7 @@ fn finish_backup ( #[sortable] pub const API_METHOD_DYNAMIC_CHUNK_INDEX: ApiMethod = ApiMethod::new( - &ApiHandler::Async(&dynamic_chunk_index), + &ApiHandler::AsyncHttp(&dynamic_chunk_index), &ObjectSchema::new( r###" Download the dynamic chunk index from the previous backup. @@ -628,7 +628,7 @@ fn dynamic_chunk_index( #[sortable] pub const API_METHOD_FIXED_CHUNK_INDEX: ApiMethod = ApiMethod::new( - &ApiHandler::Async(&fixed_chunk_index), + &ApiHandler::AsyncHttp(&fixed_chunk_index), &ObjectSchema::new( r###" Download the fixed chunk index from the previous backup. diff --git a/src/api2/backup/upload_chunk.rs b/src/api2/backup/upload_chunk.rs index 4990b7fd..3a9577ef 100644 --- a/src/api2/backup/upload_chunk.rs +++ b/src/api2/backup/upload_chunk.rs @@ -85,7 +85,7 @@ impl Future for UploadChunk { #[sortable] pub const API_METHOD_UPLOAD_FIXED_CHUNK: ApiMethod = ApiMethod::new( - &ApiHandler::Async(&upload_fixed_chunk), + &ApiHandler::AsyncHttp(&upload_fixed_chunk), &ObjectSchema::new( "Upload a new chunk.", &sorted!([ @@ -143,7 +143,7 @@ fn upload_fixed_chunk( #[sortable] pub const API_METHOD_UPLOAD_DYNAMIC_CHUNK: ApiMethod = ApiMethod::new( - &ApiHandler::Async(&upload_dynamic_chunk), + &ApiHandler::AsyncHttp(&upload_dynamic_chunk), &ObjectSchema::new( "Upload a new chunk.", &sorted!([ @@ -199,7 +199,7 @@ fn upload_dynamic_chunk( } pub const API_METHOD_UPLOAD_SPEEDTEST: ApiMethod = ApiMethod::new( - &ApiHandler::Async(&upload_speedtest), + &ApiHandler::AsyncHttp(&upload_speedtest), &ObjectSchema::new("Test upload speed.", &[]) ); @@ -237,7 +237,7 @@ fn upload_speedtest( #[sortable] pub const API_METHOD_UPLOAD_BLOB: ApiMethod = ApiMethod::new( - &ApiHandler::Async(&upload_blob), + &ApiHandler::AsyncHttp(&upload_blob), &ObjectSchema::new( "Upload binary blob file.", &sorted!([ diff --git a/src/api2/reader.rs b/src/api2/reader.rs index efd04bdf..e146f2c6 100644 --- a/src/api2/reader.rs +++ b/src/api2/reader.rs @@ -24,7 +24,7 @@ pub const ROUTER: Router = Router::new() #[sortable] pub const API_METHOD_UPGRADE_BACKUP: ApiMethod = ApiMethod::new( - &ApiHandler::Async(&upgrade_to_backup_reader_protocol), + &ApiHandler::AsyncHttp(&upgrade_to_backup_reader_protocol), &ObjectSchema::new( concat!("Upgraded to backup protocol ('", PROXMOX_BACKUP_READER_PROTOCOL_ID_V1!(), "')."), &sorted!([ @@ -157,7 +157,7 @@ pub const READER_API_ROUTER: Router = Router::new() #[sortable] pub const API_METHOD_DOWNLOAD_FILE: ApiMethod = ApiMethod::new( - &ApiHandler::Async(&download_file), + &ApiHandler::AsyncHttp(&download_file), &ObjectSchema::new( "Download specified file.", &sorted!([ @@ -208,7 +208,7 @@ fn download_file( #[sortable] pub const API_METHOD_DOWNLOAD_CHUNK: ApiMethod = ApiMethod::new( - &ApiHandler::Async(&download_chunk), + &ApiHandler::AsyncHttp(&download_chunk), &ObjectSchema::new( "Download specified chunk.", &sorted!([ @@ -293,7 +293,7 @@ fn download_chunk_old( */ pub const API_METHOD_SPEEDTEST: ApiMethod = ApiMethod::new( - &ApiHandler::Async(&speedtest), + &ApiHandler::AsyncHttp(&speedtest), &ObjectSchema::new("Test 4M block download speed.", &[]) ); diff --git a/src/cli/command.rs b/src/cli/command.rs index 39e83854..75782543 100644 --- a/src/cli/command.rs +++ b/src/cli/command.rs @@ -201,9 +201,11 @@ fn handle_simple_command( } } } - ApiHandler::Async(_) => { - //fixme - unimplemented!(); + ApiHandler::AsyncHttp(_) => { + let err = format_err!( + "CliHandler does not support ApiHandler::AsyncHttp - internal error"); + print_simple_usage_error(prefix, cli_cmd, err); + std::process::exit(-1); } } } diff --git a/src/server/rest.rs b/src/server/rest.rs index 5763d8bb..e20fa798 100644 --- a/src/server/rest.rs +++ b/src/server/rest.rs @@ -275,7 +275,7 @@ pub async fn handle_api_request { + ApiHandler::AsyncHttp(handler) => { let params = parse_query_parameters(info.parameters, "", &parts, &uri_param)?; (handler)(parts, req_body, params, info, Box::new(rpcenv)).await }