From d906b1124f0215130563d51073da9983f2d241d3 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 8 May 2019 11:36:43 +0200 Subject: [PATCH] src/api2/admin/datastore/h2upload.rs: code cleanups --- src/api2/admin/datastore/h2upload.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/api2/admin/datastore/h2upload.rs b/src/api2/admin/datastore/h2upload.rs index 5e51ccd2..075a5f82 100644 --- a/src/api2/admin/datastore/h2upload.rs +++ b/src/api2/admin/datastore/h2upload.rs @@ -3,7 +3,6 @@ use lazy_static::lazy_static; use std::collections::HashMap; use std::sync::Arc; -use std::any::Any; use futures::*; use hyper::header::{HeaderValue, UPGRADE}; @@ -69,7 +68,7 @@ impl RpcEnvironment for BackupEnvironment { self.env_type } - fn set_user(&mut self, user: Option) { + fn set_user(&mut self, _user: Option) { panic!("unable to change user"); } @@ -268,6 +267,10 @@ fn backup_api() -> Router { router } +fn get_backup_environment(rpcenv: &mut RpcEnvironment) -> &BackupEnvironment { + rpcenv.as_any().downcast_ref::().unwrap() +} + fn test1_get ( _param: Value, _info: &ApiMethod, @@ -276,7 +279,7 @@ fn test1_get ( println!("TYPEID {:?}", (*rpcenv).type_id()); - let env = rpcenv.as_any().downcast_ref::().unwrap(); + let env = get_backup_environment(rpcenv); env.log("Inside test1_get()");