From dd5495d6dccae56e3a7693c4a3a584c5d4dbe90b Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 7 Jun 2019 13:10:56 +0200 Subject: [PATCH] tree-wide: use 'dyn' for all trait objects Signed-off-by: Wolfgang Bumiller --- src/api2/access.rs | 2 +- src/api2/admin/datastore.rs | 18 +++++++++--------- src/api2/admin/datastore/pxar.rs | 4 ++-- src/api2/backup.rs | 20 ++++++++++---------- src/api2/backup/environment.rs | 5 +++-- src/api2/backup/service.rs | 2 +- src/api2/backup/upload_chunk.rs | 8 ++++---- src/api2/config/datastore.rs | 6 +++--- src/api2/node/dns.rs | 4 ++-- src/api2/node/network.rs | 2 +- src/api2/node/services.rs | 12 ++++++------ src/api2/node/syslog.rs | 2 +- src/api2/node/tasks.rs | 8 ++++---- src/api2/node/time.rs | 4 ++-- src/api2/subscription.rs | 2 +- src/api2/version.rs | 2 +- src/api_schema/router.rs | 6 +++--- src/backup/dynamic_index.rs | 2 +- src/bin/proxmox-backup-client.rs | 16 ++++++++-------- src/bin/pxar.rs | 8 ++++---- src/client/http_client.rs | 2 +- src/server/formatter.rs | 6 +++--- src/server/rest.rs | 6 +++--- src/tools.rs | 4 ++-- src/tools/broadcast_future.rs | 8 ++++---- src/tools/fs.rs | 5 +++-- 26 files changed, 83 insertions(+), 81 deletions(-) diff --git a/src/api2/access.rs b/src/api2/access.rs index a3099083..129997be 100644 --- a/src/api2/access.rs +++ b/src/api2/access.rs @@ -37,7 +37,7 @@ fn authenticate_user(username: &str, password: &str) -> Result<(), Error> { fn create_ticket( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let username = tools::required_string_param(¶m, "username")?; diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index 5b71e698..33adc36d 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -56,7 +56,7 @@ fn mark_selections, &BackupInfo) -> String> ( fn list_groups( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let store = param["store"].as_str().unwrap(); @@ -91,7 +91,7 @@ fn list_groups( fn list_snapshot_files ( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let store = tools::required_string_param(¶m, "store")?; @@ -112,7 +112,7 @@ fn list_snapshot_files ( fn delete_snapshots ( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let store = tools::required_string_param(¶m, "store")?; @@ -132,7 +132,7 @@ fn delete_snapshots ( fn list_snapshots ( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let store = tools::required_string_param(¶m, "store")?; @@ -164,7 +164,7 @@ fn list_snapshots ( fn prune( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let store = param["store"].as_str().unwrap(); @@ -272,7 +272,7 @@ fn api_method_prune() -> ApiMethod { fn start_garbage_collection( param: Value, _info: &ApiMethod, - rpcenv: &mut RpcEnvironment, + rpcenv: &mut dyn RpcEnvironment, ) -> Result { let store = param["store"].as_str().unwrap().to_string(); @@ -304,7 +304,7 @@ pub fn api_method_start_garbage_collection() -> ApiMethod { fn garbage_collection_status( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let store = param["store"].as_str().unwrap(); @@ -329,7 +329,7 @@ pub fn api_method_garbage_collection_status() -> ApiMethod { fn get_backup_list( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { //let config = datastore::config()?; @@ -359,7 +359,7 @@ fn get_backup_list( fn get_datastore_list( _param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let config = datastore::config()?; diff --git a/src/api2/admin/datastore/pxar.rs b/src/api2/admin/datastore/pxar.rs index 88af9bdc..1bd98e90 100644 --- a/src/api2/admin/datastore/pxar.rs +++ b/src/api2/admin/datastore/pxar.rs @@ -51,7 +51,7 @@ fn upload_pxar( req_body: Body, param: Value, _info: &ApiAsyncMethod, - rpcenv: Box, + rpcenv: Box, ) -> Result { let store = tools::required_string_param(¶m, "store")?; @@ -150,7 +150,7 @@ fn download_pxar( _req_body: Body, param: Value, _info: &ApiAsyncMethod, - _rpcenv: Box, + _rpcenv: Box, ) -> Result { let store = tools::required_string_param(¶m, "store")?; diff --git a/src/api2/backup.rs b/src/api2/backup.rs index b32e93e7..5a1146f7 100644 --- a/src/api2/backup.rs +++ b/src/api2/backup.rs @@ -48,7 +48,7 @@ fn upgrade_to_backup_protocol( req_body: Body, param: Value, _info: &ApiAsyncMethod, - rpcenv: Box, + rpcenv: Box, ) -> Result { let debug = param["debug"].as_bool().unwrap_or(false); @@ -213,7 +213,7 @@ pub fn api_method_create_dynamic_index() -> ApiMethod { fn create_dynamic_index( param: Value, _info: &ApiMethod, - rpcenv: &mut RpcEnvironment, + rpcenv: &mut dyn RpcEnvironment, ) -> Result { let env: &BackupEnvironment = rpcenv.as_ref(); @@ -252,7 +252,7 @@ pub fn api_method_create_fixed_index() -> ApiMethod { fn create_fixed_index( param: Value, _info: &ApiMethod, - rpcenv: &mut RpcEnvironment, + rpcenv: &mut dyn RpcEnvironment, ) -> Result { let env: &BackupEnvironment = rpcenv.as_ref(); @@ -306,7 +306,7 @@ pub fn api_method_dynamic_append() -> ApiMethod { fn dynamic_append ( param: Value, _info: &ApiMethod, - rpcenv: &mut RpcEnvironment, + rpcenv: &mut dyn RpcEnvironment, ) -> Result { let wid = tools::required_integer_param(¶m, "wid")? as usize; @@ -359,7 +359,7 @@ pub fn api_method_fixed_append() -> ApiMethod { fn fixed_append ( param: Value, _info: &ApiMethod, - rpcenv: &mut RpcEnvironment, + rpcenv: &mut dyn RpcEnvironment, ) -> Result { let wid = tools::required_integer_param(¶m, "wid")? as usize; @@ -408,7 +408,7 @@ pub fn api_method_close_dynamic_index() -> ApiMethod { fn close_dynamic_index ( param: Value, _info: &ApiMethod, - rpcenv: &mut RpcEnvironment, + rpcenv: &mut dyn RpcEnvironment, ) -> Result { let wid = tools::required_integer_param(¶m, "wid")? as usize; @@ -444,7 +444,7 @@ pub fn api_method_close_fixed_index() -> ApiMethod { fn close_fixed_index ( param: Value, _info: &ApiMethod, - rpcenv: &mut RpcEnvironment, + rpcenv: &mut dyn RpcEnvironment, ) -> Result { let wid = tools::required_integer_param(¶m, "wid")? as usize; @@ -463,7 +463,7 @@ fn close_fixed_index ( fn finish_backup ( _param: Value, _info: &ApiMethod, - rpcenv: &mut RpcEnvironment, + rpcenv: &mut dyn RpcEnvironment, ) -> Result { let env: &BackupEnvironment = rpcenv.as_ref(); @@ -491,7 +491,7 @@ fn dynamic_chunk_index( _req_body: Body, param: Value, _info: &ApiAsyncMethod, - rpcenv: Box, + rpcenv: Box, ) -> Result { let env: &BackupEnvironment = rpcenv.as_ref(); @@ -564,7 +564,7 @@ fn fixed_chunk_index( _req_body: Body, param: Value, _info: &ApiAsyncMethod, - rpcenv: Box, + rpcenv: Box, ) -> Result { let env: &BackupEnvironment = rpcenv.as_ref(); diff --git a/src/api2/backup/environment.rs b/src/api2/backup/environment.rs index 006a2dce..9184b3ef 100644 --- a/src/api2/backup/environment.rs +++ b/src/api2/backup/environment.rs @@ -440,12 +440,13 @@ impl RpcEnvironment for BackupEnvironment { } } -impl AsRef for RpcEnvironment { +impl AsRef for dyn RpcEnvironment { fn as_ref(&self) -> &BackupEnvironment { self.as_any().downcast_ref::().unwrap() } } -impl AsRef for Box { + +impl AsRef for Box { fn as_ref(&self) -> &BackupEnvironment { self.as_any().downcast_ref::().unwrap() } diff --git a/src/api2/backup/service.rs b/src/api2/backup/service.rs index ca9dd029..0275c8b8 100644 --- a/src/api2/backup/service.rs +++ b/src/api2/backup/service.rs @@ -86,7 +86,7 @@ impl hyper::service::Service for BackupService { type ReqBody = Body; type ResBody = Body; type Error = Error; - type Future = Box, Error = Self::Error> + Send>; + type Future = Box, Error = Self::Error> + Send>; fn call(&mut self, req: Request) -> Self::Future { let path = req.uri().path().to_owned(); diff --git a/src/api2/backup/upload_chunk.rs b/src/api2/backup/upload_chunk.rs index 1cc674b3..0bfe2a40 100644 --- a/src/api2/backup/upload_chunk.rs +++ b/src/api2/backup/upload_chunk.rs @@ -74,7 +74,7 @@ fn upload_fixed_chunk( req_body: Body, param: Value, _info: &ApiAsyncMethod, - rpcenv: Box, + rpcenv: Box, ) -> Result { let wid = tools::required_integer_param(¶m, "wid")? as usize; @@ -121,7 +121,7 @@ fn upload_dynamic_chunk( req_body: Body, param: Value, _info: &ApiAsyncMethod, - rpcenv: Box, + rpcenv: Box, ) -> Result { let wid = tools::required_integer_param(¶m, "wid")? as usize; @@ -160,7 +160,7 @@ fn upload_speedtest( req_body: Body, _param: Value, _info: &ApiAsyncMethod, - rpcenv: Box, + rpcenv: Box, ) -> Result { let resp = req_body @@ -203,7 +203,7 @@ fn upload_config( req_body: Body, param: Value, _info: &ApiAsyncMethod, - rpcenv: Box, + rpcenv: Box, ) -> Result { let mut file_name = tools::required_string_param(¶m, "file-name")?.to_owned(); diff --git a/src/api2/config/datastore.rs b/src/api2/config/datastore.rs index e63a9f91..37a29368 100644 --- a/src/api2/config/datastore.rs +++ b/src/api2/config/datastore.rs @@ -18,7 +18,7 @@ pub fn get() -> ApiMethod { fn get_datastore_list( _param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let config = datastore::config()?; @@ -38,7 +38,7 @@ pub fn post() -> ApiMethod { fn create_datastore( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { // fixme: locking ? @@ -75,7 +75,7 @@ pub fn delete() -> ApiMethod { fn delete_datastore( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { println!("This is a test {}", param); diff --git a/src/api2/node/dns.rs b/src/api2/node/dns.rs index 12a83294..f78d5179 100644 --- a/src/api2/node/dns.rs +++ b/src/api2/node/dns.rs @@ -54,7 +54,7 @@ fn read_etc_resolv_conf() -> Result { fn update_dns( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { lazy_static! { @@ -100,7 +100,7 @@ fn update_dns( fn get_dns( _param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { read_etc_resolv_conf() diff --git a/src/api2/node/network.rs b/src/api2/node/network.rs index a236c429..c390e216 100644 --- a/src/api2/node/network.rs +++ b/src/api2/node/network.rs @@ -10,7 +10,7 @@ use crate::api2::types::*; fn get_network_config( _param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { Ok(json!({})) diff --git a/src/api2/node/services.rs b/src/api2/node/services.rs index 56c3ad09..9a1ccfe3 100644 --- a/src/api2/node/services.rs +++ b/src/api2/node/services.rs @@ -94,7 +94,7 @@ fn json_service_state(service: &str, status: Value) -> Value { fn list_services( _param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let mut list = vec![]; @@ -117,7 +117,7 @@ fn list_services( fn get_service_state( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let service = tools::required_string_param(¶m, "service")?; @@ -162,7 +162,7 @@ fn run_service_command(service: &str, cmd: &str) -> Result { fn start_service( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let service = tools::required_string_param(¶m, "service")?; @@ -175,7 +175,7 @@ fn start_service( fn stop_service( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let service = tools::required_string_param(¶m, "service")?; @@ -188,7 +188,7 @@ fn stop_service( fn restart_service( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let service = tools::required_string_param(¶m, "service")?; @@ -206,7 +206,7 @@ fn restart_service( fn reload_service( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let service = tools::required_string_param(¶m, "service")?; diff --git a/src/api2/node/syslog.rs b/src/api2/node/syslog.rs index aeb39577..128b94a9 100644 --- a/src/api2/node/syslog.rs +++ b/src/api2/node/syslog.rs @@ -76,7 +76,7 @@ fn dump_journal( fn get_syslog( param: Value, _info: &ApiMethod, - rpcenv: &mut RpcEnvironment, + rpcenv: &mut dyn RpcEnvironment, ) -> Result { let (count, lines) = dump_journal( diff --git a/src/api2/node/tasks.rs b/src/api2/node/tasks.rs index 942d68a6..0b539780 100644 --- a/src/api2/node/tasks.rs +++ b/src/api2/node/tasks.rs @@ -14,7 +14,7 @@ use crate::server::{self, UPID}; fn get_task_status( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let upid = extract_upid(¶m)?; @@ -56,7 +56,7 @@ fn extract_upid(param: &Value) -> Result { fn read_task_log( param: Value, _info: &ApiMethod, - rpcenv: &mut RpcEnvironment, + rpcenv: &mut dyn RpcEnvironment, ) -> Result { let upid = extract_upid(¶m)?; @@ -96,7 +96,7 @@ fn read_task_log( fn stop_task( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let upid = extract_upid(¶m)?; @@ -111,7 +111,7 @@ fn stop_task( fn list_tasks( param: Value, _info: &ApiMethod, - rpcenv: &mut RpcEnvironment, + rpcenv: &mut dyn RpcEnvironment, ) -> Result { let start = param["start"].as_u64().unwrap_or(0); diff --git a/src/api2/node/time.rs b/src/api2/node/time.rs index c53a7a7a..8d850d58 100644 --- a/src/api2/node/time.rs +++ b/src/api2/node/time.rs @@ -35,7 +35,7 @@ fn read_etc_localtime() -> Result { fn get_time( _param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let datetime = Local::now(); @@ -53,7 +53,7 @@ fn get_time( fn set_timezone( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let timezone = tools::required_string_param(¶m, "timezone")?; diff --git a/src/api2/subscription.rs b/src/api2/subscription.rs index 5ebd6027..058c692d 100644 --- a/src/api2/subscription.rs +++ b/src/api2/subscription.rs @@ -9,7 +9,7 @@ use serde_json::{json, Value}; fn get_subscription( _param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let url = "https://www.proxmox.com/en/proxmox-backup-server/pricing"; diff --git a/src/api2/version.rs b/src/api2/version.rs index 381a8895..8c18debe 100644 --- a/src/api2/version.rs +++ b/src/api2/version.rs @@ -11,7 +11,7 @@ const PROXMOX_PKG_REPOID: &'static str = env!("PROXMOX_PKG_REPOID"); fn get_version( _param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { Ok(json!({ diff --git a/src/api_schema/router.rs b/src/api_schema/router.rs index 10271172..4e3df200 100644 --- a/src/api_schema/router.rs +++ b/src/api_schema/router.rs @@ -12,7 +12,7 @@ use hyper::http::request::Parts; use super::api_handler::*; -pub type BoxFut = Box, Error = failure::Error> + Send>; +pub type BoxFut = Box, Error = failure::Error> + Send>; /// Abstract Interface for API methods to interact with the environment pub trait RpcEnvironment: std::any::Any + crate::tools::AsAny + Send { @@ -75,7 +75,7 @@ macro_rules! http_err { } type ApiAsyncHandlerFn = Box< - dyn Fn(Parts, Body, Value, &ApiAsyncMethod, Box) -> Result + dyn Fn(Parts, Body, Value, &ApiAsyncMethod, Box) -> Result + Send + Sync + 'static >; @@ -152,7 +152,7 @@ impl ApiAsyncMethod { pub fn new(handler: F, parameters: ObjectSchema) -> Self where - F: Fn(Parts, Body, Value, &ApiAsyncMethod, Box) -> Result + F: Fn(Parts, Body, Value, &ApiAsyncMethod, Box) -> Result + Send + Sync + 'static, { Self { diff --git a/src/backup/dynamic_index.rs b/src/backup/dynamic_index.rs index 11073fbf..c93aae11 100644 --- a/src/backup/dynamic_index.rs +++ b/src/backup/dynamic_index.rs @@ -180,7 +180,7 @@ impl DynamicIndexReader { Ok(()) } - pub fn dump_pxar(&self, mut writer: Box) -> Result<(), Error> { + pub fn dump_pxar(&self, mut writer: Box) -> Result<(), Error> { let mut buffer = Vec::with_capacity(1024*1024); diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs index 7e590972..440c5753 100644 --- a/src/bin/proxmox-backup-client.rs +++ b/src/bin/proxmox-backup-client.rs @@ -179,7 +179,7 @@ fn strip_chunked_file_expenstions(list: Vec) -> Vec { fn list_backups( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let repo_url = tools::required_string_param(¶m, "repository")?; @@ -221,7 +221,7 @@ fn list_backups( fn list_backup_groups( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let repo_url = tools::required_string_param(¶m, "repository")?; @@ -278,7 +278,7 @@ fn list_backup_groups( fn list_snapshots( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let repo_url = tools::required_string_param(¶m, "repository")?; @@ -323,7 +323,7 @@ fn list_snapshots( fn forget_snapshots( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let repo_url = tools::required_string_param(¶m, "repository")?; @@ -350,7 +350,7 @@ fn forget_snapshots( fn start_garbage_collection( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let repo_url = tools::required_string_param(¶m, "repository")?; @@ -378,7 +378,7 @@ fn parse_backupspec(value: &str) -> Result<(&str, &str), Error> { fn create_backup( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let repo_url = tools::required_string_param(¶m, "repository")?; @@ -510,7 +510,7 @@ fn complete_backup_source(arg: &str, param: &HashMap) -> Vec Result { let repo_url = tools::required_string_param(¶m, "repository")?; @@ -577,7 +577,7 @@ fn restore( fn prune( mut param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let repo_url = tools::required_string_param(¶m, "repository")?; diff --git a/src/bin/pxar.rs b/src/bin/pxar.rs index 4675ca1f..27a5533f 100644 --- a/src/bin/pxar.rs +++ b/src/bin/pxar.rs @@ -19,7 +19,7 @@ use proxmox_backup::pxar; fn print_filenames( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let archive = tools::required_string_param(¶m, "archive")?; @@ -44,7 +44,7 @@ fn print_filenames( fn dump_archive( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let archive = tools::required_string_param(¶m, "archive")?; @@ -81,7 +81,7 @@ fn dump_archive( fn extract_archive( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let archive = tools::required_string_param(¶m, "archive")?; @@ -120,7 +120,7 @@ fn extract_archive( fn create_archive( param: Value, _info: &ApiMethod, - _rpcenv: &mut RpcEnvironment, + _rpcenv: &mut dyn RpcEnvironment, ) -> Result { let archive = tools::required_string_param(¶m, "archive")?; diff --git a/src/client/http_client.rs b/src/client/http_client.rs index c810d2f1..25bf33a3 100644 --- a/src/client/http_client.rs +++ b/src/client/http_client.rs @@ -315,7 +315,7 @@ impl HttpClient { server: String, username: String, password: String, - ) -> Box + Send> { + ) -> Box + Send> { let server2 = server.clone(); diff --git a/src/server/formatter.rs b/src/server/formatter.rs index 28380937..ca2a6e73 100644 --- a/src/server/formatter.rs +++ b/src/server/formatter.rs @@ -11,7 +11,7 @@ pub struct ErrorMessageExtension(pub String); pub struct OutputFormatter { - pub format_data: fn(data: Value, rpcenv: &RpcEnvironment) -> Response, + pub format_data: fn(data: Value, rpcenv: &dyn RpcEnvironment) -> Response, pub format_error: fn(err: Error) -> Response, } @@ -39,7 +39,7 @@ pub fn json_data_response(data: Value) -> Response { response } -fn json_format_data(data: Value, rpcenv: &RpcEnvironment) -> Response { +fn json_format_data(data: Value, rpcenv: &dyn RpcEnvironment) -> Response { let mut result = json!({ "data": data @@ -82,7 +82,7 @@ pub static JSON_FORMATTER: OutputFormatter = OutputFormatter { format_error: json_error_response, }; -fn extjs_format_data(data: Value, rpcenv: &RpcEnvironment) -> Response { +fn extjs_format_data(data: Value, rpcenv: &dyn RpcEnvironment) -> Response { let mut result = json!({ "data": data, diff --git a/src/server/rest.rs b/src/server/rest.rs index fe6172ba..445af4de 100644 --- a/src/server/rest.rs +++ b/src/server/rest.rs @@ -47,7 +47,7 @@ impl NewService for RestServer type Error = hyper::Error; type InitError = hyper::Error; type Service = ApiService; - type Future = Box + Send>; + type Future = Box + Send>; fn new_service(&self) -> Self::Future { Box::new(future::ok(ApiService { api_config: self.api_config.clone() })) } @@ -80,7 +80,7 @@ impl Service for ApiService { type ReqBody = Body; type ResBody = Body; type Error = hyper::Error; - type Future = Box, Error = Self::Error> + Send>; + type Future = Box, Error = Self::Error> + Send>; fn call(&mut self, req: Request) -> Self::Future { let path = req.uri().path().to_owned(); @@ -115,7 +115,7 @@ fn get_request_parameters_async( parts: Parts, req_body: Body, uri_param: HashMap, -) -> Box + Send> +) -> Box + Send> { let mut is_json = false; diff --git a/src/tools.rs b/src/tools.rs index d4c97235..78a01625 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -749,11 +749,11 @@ pub fn pipe() -> Result<(Fd, Fd), Error> { /// /// Mostly useful to downcast trait objects (see RpcEnvironment). pub trait AsAny { - fn as_any(&self) -> &Any; + fn as_any(&self) -> &dyn Any; } impl AsAny for T { - fn as_any(&self) -> &Any { self } + fn as_any(&self) -> &dyn Any { self } } diff --git a/src/tools/broadcast_future.rs b/src/tools/broadcast_future.rs index cca7e4d5..924b6441 100644 --- a/src/tools/broadcast_future.rs +++ b/src/tools/broadcast_future.rs @@ -54,7 +54,7 @@ impl BroadcastData { /// Broadcast future results to registered listeners pub struct BroadcastFuture { - inner: Arc, Option + Send>>)>>, + inner: Arc, Option + Send>>)>>, } impl BroadcastFuture { @@ -62,7 +62,7 @@ impl BroadcastFuture { /// Create instance for specified source future. /// /// The result of the future is sent to all registered listeners. - pub fn new(source: Box + Send>) -> Self { + pub fn new(source: Box + Send>) -> Self { Self { inner: Arc::new(Mutex::new((BroadcastData::new(), Some(source)))) } } @@ -76,12 +76,12 @@ impl BroadcastFuture { (Self::new(test), tx) } - fn notify_listeners(inner: Arc, Option + Send>>)>>, result: Result) { + fn notify_listeners(inner: Arc, Option + Send>>)>>, result: Result) { let mut data = inner.lock().unwrap(); data.0.notify_listeners(result); } - fn spawn(inner: Arc, Option + Send>>)>>) -> impl Future { + fn spawn(inner: Arc, Option + Send>>)>>) -> impl Future { let mut data = inner.lock().unwrap(); diff --git a/src/tools/fs.rs b/src/tools/fs.rs index d562c0fb..628d42fc 100644 --- a/src/tools/fs.rs +++ b/src/tools/fs.rs @@ -76,7 +76,7 @@ impl ReadDirEntry { // This is simply a wrapper with a shorter type name mapping nix::Error to failure::Error. /// Wrapper over a pair of `nix::dir::Dir` and `nix::dir::Iter`, returned by `read_subdir()`. pub struct ReadDir { - iter: Tied> + Send>, + iter: Tied> + Send>, dir_fd: RawFd, } @@ -100,7 +100,8 @@ pub fn read_subdir(dirfd: RawFd, path: &P) -> Result> + Send> + Box::new(unsafe { (*dir).iter() }) + as Box> + Send> }); Ok(ReadDir { iter, dir_fd: fd }) } -- 2.39.2