tree-wide: use 'dyn' for all trait objects
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
e993db91cd
commit
dd5495d6dc
@ -37,7 +37,7 @@ fn authenticate_user(username: &str, password: &str) -> Result<(), Error> {
|
|||||||
fn create_ticket(
|
fn create_ticket(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let username = tools::required_string_param(¶m, "username")?;
|
let username = tools::required_string_param(¶m, "username")?;
|
||||||
|
@ -56,7 +56,7 @@ fn mark_selections<F: Fn(DateTime<Local>, &BackupInfo) -> String> (
|
|||||||
fn list_groups(
|
fn list_groups(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let store = param["store"].as_str().unwrap();
|
let store = param["store"].as_str().unwrap();
|
||||||
@ -91,7 +91,7 @@ fn list_groups(
|
|||||||
fn list_snapshot_files (
|
fn list_snapshot_files (
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let store = tools::required_string_param(¶m, "store")?;
|
let store = tools::required_string_param(¶m, "store")?;
|
||||||
@ -112,7 +112,7 @@ fn list_snapshot_files (
|
|||||||
fn delete_snapshots (
|
fn delete_snapshots (
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let store = tools::required_string_param(¶m, "store")?;
|
let store = tools::required_string_param(¶m, "store")?;
|
||||||
@ -132,7 +132,7 @@ fn delete_snapshots (
|
|||||||
fn list_snapshots (
|
fn list_snapshots (
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let store = tools::required_string_param(¶m, "store")?;
|
let store = tools::required_string_param(¶m, "store")?;
|
||||||
@ -164,7 +164,7 @@ fn list_snapshots (
|
|||||||
fn prune(
|
fn prune(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let store = param["store"].as_str().unwrap();
|
let store = param["store"].as_str().unwrap();
|
||||||
@ -272,7 +272,7 @@ fn api_method_prune() -> ApiMethod {
|
|||||||
fn start_garbage_collection(
|
fn start_garbage_collection(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
rpcenv: &mut RpcEnvironment,
|
rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let store = param["store"].as_str().unwrap().to_string();
|
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(
|
fn garbage_collection_status(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let store = param["store"].as_str().unwrap();
|
let store = param["store"].as_str().unwrap();
|
||||||
@ -329,7 +329,7 @@ pub fn api_method_garbage_collection_status() -> ApiMethod {
|
|||||||
fn get_backup_list(
|
fn get_backup_list(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
//let config = datastore::config()?;
|
//let config = datastore::config()?;
|
||||||
@ -359,7 +359,7 @@ fn get_backup_list(
|
|||||||
fn get_datastore_list(
|
fn get_datastore_list(
|
||||||
_param: Value,
|
_param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let config = datastore::config()?;
|
let config = datastore::config()?;
|
||||||
|
@ -51,7 +51,7 @@ fn upload_pxar(
|
|||||||
req_body: Body,
|
req_body: Body,
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiAsyncMethod,
|
_info: &ApiAsyncMethod,
|
||||||
rpcenv: Box<RpcEnvironment>,
|
rpcenv: Box<dyn RpcEnvironment>,
|
||||||
) -> Result<BoxFut, Error> {
|
) -> Result<BoxFut, Error> {
|
||||||
|
|
||||||
let store = tools::required_string_param(¶m, "store")?;
|
let store = tools::required_string_param(¶m, "store")?;
|
||||||
@ -150,7 +150,7 @@ fn download_pxar(
|
|||||||
_req_body: Body,
|
_req_body: Body,
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiAsyncMethod,
|
_info: &ApiAsyncMethod,
|
||||||
_rpcenv: Box<RpcEnvironment>,
|
_rpcenv: Box<dyn RpcEnvironment>,
|
||||||
) -> Result<BoxFut, Error> {
|
) -> Result<BoxFut, Error> {
|
||||||
|
|
||||||
let store = tools::required_string_param(¶m, "store")?;
|
let store = tools::required_string_param(¶m, "store")?;
|
||||||
|
@ -48,7 +48,7 @@ fn upgrade_to_backup_protocol(
|
|||||||
req_body: Body,
|
req_body: Body,
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiAsyncMethod,
|
_info: &ApiAsyncMethod,
|
||||||
rpcenv: Box<RpcEnvironment>,
|
rpcenv: Box<dyn RpcEnvironment>,
|
||||||
) -> Result<BoxFut, Error> {
|
) -> Result<BoxFut, Error> {
|
||||||
|
|
||||||
let debug = param["debug"].as_bool().unwrap_or(false);
|
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(
|
fn create_dynamic_index(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
rpcenv: &mut RpcEnvironment,
|
rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let env: &BackupEnvironment = rpcenv.as_ref();
|
let env: &BackupEnvironment = rpcenv.as_ref();
|
||||||
@ -252,7 +252,7 @@ pub fn api_method_create_fixed_index() -> ApiMethod {
|
|||||||
fn create_fixed_index(
|
fn create_fixed_index(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
rpcenv: &mut RpcEnvironment,
|
rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let env: &BackupEnvironment = rpcenv.as_ref();
|
let env: &BackupEnvironment = rpcenv.as_ref();
|
||||||
@ -306,7 +306,7 @@ pub fn api_method_dynamic_append() -> ApiMethod {
|
|||||||
fn dynamic_append (
|
fn dynamic_append (
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
rpcenv: &mut RpcEnvironment,
|
rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let wid = tools::required_integer_param(¶m, "wid")? as usize;
|
let wid = tools::required_integer_param(¶m, "wid")? as usize;
|
||||||
@ -359,7 +359,7 @@ pub fn api_method_fixed_append() -> ApiMethod {
|
|||||||
fn fixed_append (
|
fn fixed_append (
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
rpcenv: &mut RpcEnvironment,
|
rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let wid = tools::required_integer_param(¶m, "wid")? as usize;
|
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 (
|
fn close_dynamic_index (
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
rpcenv: &mut RpcEnvironment,
|
rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let wid = tools::required_integer_param(¶m, "wid")? as usize;
|
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 (
|
fn close_fixed_index (
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
rpcenv: &mut RpcEnvironment,
|
rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let wid = tools::required_integer_param(¶m, "wid")? as usize;
|
let wid = tools::required_integer_param(¶m, "wid")? as usize;
|
||||||
@ -463,7 +463,7 @@ fn close_fixed_index (
|
|||||||
fn finish_backup (
|
fn finish_backup (
|
||||||
_param: Value,
|
_param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
rpcenv: &mut RpcEnvironment,
|
rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let env: &BackupEnvironment = rpcenv.as_ref();
|
let env: &BackupEnvironment = rpcenv.as_ref();
|
||||||
@ -491,7 +491,7 @@ fn dynamic_chunk_index(
|
|||||||
_req_body: Body,
|
_req_body: Body,
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiAsyncMethod,
|
_info: &ApiAsyncMethod,
|
||||||
rpcenv: Box<RpcEnvironment>,
|
rpcenv: Box<dyn RpcEnvironment>,
|
||||||
) -> Result<BoxFut, Error> {
|
) -> Result<BoxFut, Error> {
|
||||||
|
|
||||||
let env: &BackupEnvironment = rpcenv.as_ref();
|
let env: &BackupEnvironment = rpcenv.as_ref();
|
||||||
@ -564,7 +564,7 @@ fn fixed_chunk_index(
|
|||||||
_req_body: Body,
|
_req_body: Body,
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiAsyncMethod,
|
_info: &ApiAsyncMethod,
|
||||||
rpcenv: Box<RpcEnvironment>,
|
rpcenv: Box<dyn RpcEnvironment>,
|
||||||
) -> Result<BoxFut, Error> {
|
) -> Result<BoxFut, Error> {
|
||||||
|
|
||||||
let env: &BackupEnvironment = rpcenv.as_ref();
|
let env: &BackupEnvironment = rpcenv.as_ref();
|
||||||
|
@ -440,12 +440,13 @@ impl RpcEnvironment for BackupEnvironment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRef<BackupEnvironment> for RpcEnvironment {
|
impl AsRef<BackupEnvironment> for dyn RpcEnvironment {
|
||||||
fn as_ref(&self) -> &BackupEnvironment {
|
fn as_ref(&self) -> &BackupEnvironment {
|
||||||
self.as_any().downcast_ref::<BackupEnvironment>().unwrap()
|
self.as_any().downcast_ref::<BackupEnvironment>().unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl AsRef<BackupEnvironment> for Box<RpcEnvironment> {
|
|
||||||
|
impl AsRef<BackupEnvironment> for Box<dyn RpcEnvironment> {
|
||||||
fn as_ref(&self) -> &BackupEnvironment {
|
fn as_ref(&self) -> &BackupEnvironment {
|
||||||
self.as_any().downcast_ref::<BackupEnvironment>().unwrap()
|
self.as_any().downcast_ref::<BackupEnvironment>().unwrap()
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ impl hyper::service::Service for BackupService {
|
|||||||
type ReqBody = Body;
|
type ReqBody = Body;
|
||||||
type ResBody = Body;
|
type ResBody = Body;
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
type Future = Box<Future<Item = Response<Body>, Error = Self::Error> + Send>;
|
type Future = Box<dyn Future<Item = Response<Body>, Error = Self::Error> + Send>;
|
||||||
|
|
||||||
fn call(&mut self, req: Request<Self::ReqBody>) -> Self::Future {
|
fn call(&mut self, req: Request<Self::ReqBody>) -> Self::Future {
|
||||||
let path = req.uri().path().to_owned();
|
let path = req.uri().path().to_owned();
|
||||||
|
@ -74,7 +74,7 @@ fn upload_fixed_chunk(
|
|||||||
req_body: Body,
|
req_body: Body,
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiAsyncMethod,
|
_info: &ApiAsyncMethod,
|
||||||
rpcenv: Box<RpcEnvironment>,
|
rpcenv: Box<dyn RpcEnvironment>,
|
||||||
) -> Result<BoxFut, Error> {
|
) -> Result<BoxFut, Error> {
|
||||||
|
|
||||||
let wid = tools::required_integer_param(¶m, "wid")? as usize;
|
let wid = tools::required_integer_param(¶m, "wid")? as usize;
|
||||||
@ -121,7 +121,7 @@ fn upload_dynamic_chunk(
|
|||||||
req_body: Body,
|
req_body: Body,
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiAsyncMethod,
|
_info: &ApiAsyncMethod,
|
||||||
rpcenv: Box<RpcEnvironment>,
|
rpcenv: Box<dyn RpcEnvironment>,
|
||||||
) -> Result<BoxFut, Error> {
|
) -> Result<BoxFut, Error> {
|
||||||
|
|
||||||
let wid = tools::required_integer_param(¶m, "wid")? as usize;
|
let wid = tools::required_integer_param(¶m, "wid")? as usize;
|
||||||
@ -160,7 +160,7 @@ fn upload_speedtest(
|
|||||||
req_body: Body,
|
req_body: Body,
|
||||||
_param: Value,
|
_param: Value,
|
||||||
_info: &ApiAsyncMethod,
|
_info: &ApiAsyncMethod,
|
||||||
rpcenv: Box<RpcEnvironment>,
|
rpcenv: Box<dyn RpcEnvironment>,
|
||||||
) -> Result<BoxFut, Error> {
|
) -> Result<BoxFut, Error> {
|
||||||
|
|
||||||
let resp = req_body
|
let resp = req_body
|
||||||
@ -203,7 +203,7 @@ fn upload_config(
|
|||||||
req_body: Body,
|
req_body: Body,
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiAsyncMethod,
|
_info: &ApiAsyncMethod,
|
||||||
rpcenv: Box<RpcEnvironment>,
|
rpcenv: Box<dyn RpcEnvironment>,
|
||||||
) -> Result<BoxFut, Error> {
|
) -> Result<BoxFut, Error> {
|
||||||
|
|
||||||
let mut file_name = tools::required_string_param(¶m, "file-name")?.to_owned();
|
let mut file_name = tools::required_string_param(¶m, "file-name")?.to_owned();
|
||||||
|
@ -18,7 +18,7 @@ pub fn get() -> ApiMethod {
|
|||||||
fn get_datastore_list(
|
fn get_datastore_list(
|
||||||
_param: Value,
|
_param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let config = datastore::config()?;
|
let config = datastore::config()?;
|
||||||
@ -38,7 +38,7 @@ pub fn post() -> ApiMethod {
|
|||||||
fn create_datastore(
|
fn create_datastore(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
// fixme: locking ?
|
// fixme: locking ?
|
||||||
@ -75,7 +75,7 @@ pub fn delete() -> ApiMethod {
|
|||||||
fn delete_datastore(
|
fn delete_datastore(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
println!("This is a test {}", param);
|
println!("This is a test {}", param);
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ fn read_etc_resolv_conf() -> Result<Value, Error> {
|
|||||||
fn update_dns(
|
fn update_dns(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
@ -100,7 +100,7 @@ fn update_dns(
|
|||||||
fn get_dns(
|
fn get_dns(
|
||||||
_param: Value,
|
_param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
read_etc_resolv_conf()
|
read_etc_resolv_conf()
|
||||||
|
@ -10,7 +10,7 @@ use crate::api2::types::*;
|
|||||||
fn get_network_config(
|
fn get_network_config(
|
||||||
_param: Value,
|
_param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
Ok(json!({}))
|
Ok(json!({}))
|
||||||
|
@ -94,7 +94,7 @@ fn json_service_state(service: &str, status: Value) -> Value {
|
|||||||
fn list_services(
|
fn list_services(
|
||||||
_param: Value,
|
_param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let mut list = vec![];
|
let mut list = vec![];
|
||||||
@ -117,7 +117,7 @@ fn list_services(
|
|||||||
fn get_service_state(
|
fn get_service_state(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let service = tools::required_string_param(¶m, "service")?;
|
let service = tools::required_string_param(¶m, "service")?;
|
||||||
@ -162,7 +162,7 @@ fn run_service_command(service: &str, cmd: &str) -> Result<Value, Error> {
|
|||||||
fn start_service(
|
fn start_service(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let service = tools::required_string_param(¶m, "service")?;
|
let service = tools::required_string_param(¶m, "service")?;
|
||||||
@ -175,7 +175,7 @@ fn start_service(
|
|||||||
fn stop_service(
|
fn stop_service(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let service = tools::required_string_param(¶m, "service")?;
|
let service = tools::required_string_param(¶m, "service")?;
|
||||||
@ -188,7 +188,7 @@ fn stop_service(
|
|||||||
fn restart_service(
|
fn restart_service(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let service = tools::required_string_param(¶m, "service")?;
|
let service = tools::required_string_param(¶m, "service")?;
|
||||||
@ -206,7 +206,7 @@ fn restart_service(
|
|||||||
fn reload_service(
|
fn reload_service(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let service = tools::required_string_param(¶m, "service")?;
|
let service = tools::required_string_param(¶m, "service")?;
|
||||||
|
@ -76,7 +76,7 @@ fn dump_journal(
|
|||||||
fn get_syslog(
|
fn get_syslog(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
rpcenv: &mut RpcEnvironment,
|
rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let (count, lines) = dump_journal(
|
let (count, lines) = dump_journal(
|
||||||
|
@ -14,7 +14,7 @@ use crate::server::{self, UPID};
|
|||||||
fn get_task_status(
|
fn get_task_status(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let upid = extract_upid(¶m)?;
|
let upid = extract_upid(¶m)?;
|
||||||
@ -56,7 +56,7 @@ fn extract_upid(param: &Value) -> Result<UPID, Error> {
|
|||||||
fn read_task_log(
|
fn read_task_log(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
rpcenv: &mut RpcEnvironment,
|
rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let upid = extract_upid(¶m)?;
|
let upid = extract_upid(¶m)?;
|
||||||
@ -96,7 +96,7 @@ fn read_task_log(
|
|||||||
fn stop_task(
|
fn stop_task(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let upid = extract_upid(¶m)?;
|
let upid = extract_upid(¶m)?;
|
||||||
@ -111,7 +111,7 @@ fn stop_task(
|
|||||||
fn list_tasks(
|
fn list_tasks(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
rpcenv: &mut RpcEnvironment,
|
rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let start = param["start"].as_u64().unwrap_or(0);
|
let start = param["start"].as_u64().unwrap_or(0);
|
||||||
|
@ -35,7 +35,7 @@ fn read_etc_localtime() -> Result<String, Error> {
|
|||||||
fn get_time(
|
fn get_time(
|
||||||
_param: Value,
|
_param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let datetime = Local::now();
|
let datetime = Local::now();
|
||||||
@ -53,7 +53,7 @@ fn get_time(
|
|||||||
fn set_timezone(
|
fn set_timezone(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let timezone = tools::required_string_param(¶m, "timezone")?;
|
let timezone = tools::required_string_param(¶m, "timezone")?;
|
||||||
|
@ -9,7 +9,7 @@ use serde_json::{json, Value};
|
|||||||
fn get_subscription(
|
fn get_subscription(
|
||||||
_param: Value,
|
_param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let url = "https://www.proxmox.com/en/proxmox-backup-server/pricing";
|
let url = "https://www.proxmox.com/en/proxmox-backup-server/pricing";
|
||||||
|
@ -11,7 +11,7 @@ const PROXMOX_PKG_REPOID: &'static str = env!("PROXMOX_PKG_REPOID");
|
|||||||
fn get_version(
|
fn get_version(
|
||||||
_param: Value,
|
_param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
Ok(json!({
|
Ok(json!({
|
||||||
|
@ -12,7 +12,7 @@ use hyper::http::request::Parts;
|
|||||||
|
|
||||||
use super::api_handler::*;
|
use super::api_handler::*;
|
||||||
|
|
||||||
pub type BoxFut = Box<Future<Item = Response<Body>, Error = failure::Error> + Send>;
|
pub type BoxFut = Box<dyn Future<Item = Response<Body>, Error = failure::Error> + Send>;
|
||||||
|
|
||||||
/// Abstract Interface for API methods to interact with the environment
|
/// Abstract Interface for API methods to interact with the environment
|
||||||
pub trait RpcEnvironment: std::any::Any + crate::tools::AsAny + Send {
|
pub trait RpcEnvironment: std::any::Any + crate::tools::AsAny + Send {
|
||||||
@ -75,7 +75,7 @@ macro_rules! http_err {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ApiAsyncHandlerFn = Box<
|
type ApiAsyncHandlerFn = Box<
|
||||||
dyn Fn(Parts, Body, Value, &ApiAsyncMethod, Box<RpcEnvironment>) -> Result<BoxFut, Error>
|
dyn Fn(Parts, Body, Value, &ApiAsyncMethod, Box<dyn RpcEnvironment>) -> Result<BoxFut, Error>
|
||||||
+ Send + Sync + 'static
|
+ Send + Sync + 'static
|
||||||
>;
|
>;
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ impl ApiAsyncMethod {
|
|||||||
|
|
||||||
pub fn new<F>(handler: F, parameters: ObjectSchema) -> Self
|
pub fn new<F>(handler: F, parameters: ObjectSchema) -> Self
|
||||||
where
|
where
|
||||||
F: Fn(Parts, Body, Value, &ApiAsyncMethod, Box<RpcEnvironment>) -> Result<BoxFut, Error>
|
F: Fn(Parts, Body, Value, &ApiAsyncMethod, Box<dyn RpcEnvironment>) -> Result<BoxFut, Error>
|
||||||
+ Send + Sync + 'static,
|
+ Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
Self {
|
Self {
|
||||||
|
@ -180,7 +180,7 @@ impl DynamicIndexReader {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dump_pxar(&self, mut writer: Box<Write>) -> Result<(), Error> {
|
pub fn dump_pxar(&self, mut writer: Box<dyn Write>) -> Result<(), Error> {
|
||||||
|
|
||||||
let mut buffer = Vec::with_capacity(1024*1024);
|
let mut buffer = Vec::with_capacity(1024*1024);
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ fn strip_chunked_file_expenstions(list: Vec<String>) -> Vec<String> {
|
|||||||
fn list_backups(
|
fn list_backups(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let repo_url = tools::required_string_param(¶m, "repository")?;
|
let repo_url = tools::required_string_param(¶m, "repository")?;
|
||||||
@ -221,7 +221,7 @@ fn list_backups(
|
|||||||
fn list_backup_groups(
|
fn list_backup_groups(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let repo_url = tools::required_string_param(¶m, "repository")?;
|
let repo_url = tools::required_string_param(¶m, "repository")?;
|
||||||
@ -278,7 +278,7 @@ fn list_backup_groups(
|
|||||||
fn list_snapshots(
|
fn list_snapshots(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let repo_url = tools::required_string_param(¶m, "repository")?;
|
let repo_url = tools::required_string_param(¶m, "repository")?;
|
||||||
@ -323,7 +323,7 @@ fn list_snapshots(
|
|||||||
fn forget_snapshots(
|
fn forget_snapshots(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let repo_url = tools::required_string_param(¶m, "repository")?;
|
let repo_url = tools::required_string_param(¶m, "repository")?;
|
||||||
@ -350,7 +350,7 @@ fn forget_snapshots(
|
|||||||
fn start_garbage_collection(
|
fn start_garbage_collection(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let repo_url = tools::required_string_param(¶m, "repository")?;
|
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(
|
fn create_backup(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let repo_url = tools::required_string_param(¶m, "repository")?;
|
let repo_url = tools::required_string_param(¶m, "repository")?;
|
||||||
@ -510,7 +510,7 @@ fn complete_backup_source(arg: &str, param: &HashMap<String, String>) -> Vec<Str
|
|||||||
fn restore(
|
fn restore(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let repo_url = tools::required_string_param(¶m, "repository")?;
|
let repo_url = tools::required_string_param(¶m, "repository")?;
|
||||||
@ -577,7 +577,7 @@ fn restore(
|
|||||||
fn prune(
|
fn prune(
|
||||||
mut param: Value,
|
mut param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let repo_url = tools::required_string_param(¶m, "repository")?;
|
let repo_url = tools::required_string_param(¶m, "repository")?;
|
||||||
|
@ -19,7 +19,7 @@ use proxmox_backup::pxar;
|
|||||||
fn print_filenames(
|
fn print_filenames(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let archive = tools::required_string_param(¶m, "archive")?;
|
let archive = tools::required_string_param(¶m, "archive")?;
|
||||||
@ -44,7 +44,7 @@ fn print_filenames(
|
|||||||
fn dump_archive(
|
fn dump_archive(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let archive = tools::required_string_param(¶m, "archive")?;
|
let archive = tools::required_string_param(¶m, "archive")?;
|
||||||
@ -81,7 +81,7 @@ fn dump_archive(
|
|||||||
fn extract_archive(
|
fn extract_archive(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let archive = tools::required_string_param(¶m, "archive")?;
|
let archive = tools::required_string_param(¶m, "archive")?;
|
||||||
@ -120,7 +120,7 @@ fn extract_archive(
|
|||||||
fn create_archive(
|
fn create_archive(
|
||||||
param: Value,
|
param: Value,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
|
||||||
let archive = tools::required_string_param(¶m, "archive")?;
|
let archive = tools::required_string_param(¶m, "archive")?;
|
||||||
|
@ -315,7 +315,7 @@ impl HttpClient {
|
|||||||
server: String,
|
server: String,
|
||||||
username: String,
|
username: String,
|
||||||
password: String,
|
password: String,
|
||||||
) -> Box<Future<Item=AuthInfo, Error=Error> + Send> {
|
) -> Box<dyn Future<Item=AuthInfo, Error=Error> + Send> {
|
||||||
|
|
||||||
let server2 = server.clone();
|
let server2 = server.clone();
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ pub struct ErrorMessageExtension(pub String);
|
|||||||
|
|
||||||
pub struct OutputFormatter {
|
pub struct OutputFormatter {
|
||||||
|
|
||||||
pub format_data: fn(data: Value, rpcenv: &RpcEnvironment) -> Response<Body>,
|
pub format_data: fn(data: Value, rpcenv: &dyn RpcEnvironment) -> Response<Body>,
|
||||||
|
|
||||||
pub format_error: fn(err: Error) -> Response<Body>,
|
pub format_error: fn(err: Error) -> Response<Body>,
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ pub fn json_data_response(data: Value) -> Response<Body> {
|
|||||||
response
|
response
|
||||||
}
|
}
|
||||||
|
|
||||||
fn json_format_data(data: Value, rpcenv: &RpcEnvironment) -> Response<Body> {
|
fn json_format_data(data: Value, rpcenv: &dyn RpcEnvironment) -> Response<Body> {
|
||||||
|
|
||||||
let mut result = json!({
|
let mut result = json!({
|
||||||
"data": data
|
"data": data
|
||||||
@ -82,7 +82,7 @@ pub static JSON_FORMATTER: OutputFormatter = OutputFormatter {
|
|||||||
format_error: json_error_response,
|
format_error: json_error_response,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn extjs_format_data(data: Value, rpcenv: &RpcEnvironment) -> Response<Body> {
|
fn extjs_format_data(data: Value, rpcenv: &dyn RpcEnvironment) -> Response<Body> {
|
||||||
|
|
||||||
let mut result = json!({
|
let mut result = json!({
|
||||||
"data": data,
|
"data": data,
|
||||||
|
@ -47,7 +47,7 @@ impl NewService for RestServer
|
|||||||
type Error = hyper::Error;
|
type Error = hyper::Error;
|
||||||
type InitError = hyper::Error;
|
type InitError = hyper::Error;
|
||||||
type Service = ApiService;
|
type Service = ApiService;
|
||||||
type Future = Box<Future<Item = Self::Service, Error = Self::InitError> + Send>;
|
type Future = Box<dyn Future<Item = Self::Service, Error = Self::InitError> + Send>;
|
||||||
fn new_service(&self) -> Self::Future {
|
fn new_service(&self) -> Self::Future {
|
||||||
Box::new(future::ok(ApiService { api_config: self.api_config.clone() }))
|
Box::new(future::ok(ApiService { api_config: self.api_config.clone() }))
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ impl Service for ApiService {
|
|||||||
type ReqBody = Body;
|
type ReqBody = Body;
|
||||||
type ResBody = Body;
|
type ResBody = Body;
|
||||||
type Error = hyper::Error;
|
type Error = hyper::Error;
|
||||||
type Future = Box<Future<Item = Response<Body>, Error = Self::Error> + Send>;
|
type Future = Box<dyn Future<Item = Response<Body>, Error = Self::Error> + Send>;
|
||||||
|
|
||||||
fn call(&mut self, req: Request<Self::ReqBody>) -> Self::Future {
|
fn call(&mut self, req: Request<Self::ReqBody>) -> Self::Future {
|
||||||
let path = req.uri().path().to_owned();
|
let path = req.uri().path().to_owned();
|
||||||
@ -115,7 +115,7 @@ fn get_request_parameters_async(
|
|||||||
parts: Parts,
|
parts: Parts,
|
||||||
req_body: Body,
|
req_body: Body,
|
||||||
uri_param: HashMap<String, String>,
|
uri_param: HashMap<String, String>,
|
||||||
) -> Box<Future<Item = Value, Error = failure::Error> + Send>
|
) -> Box<dyn Future<Item = Value, Error = failure::Error> + Send>
|
||||||
{
|
{
|
||||||
let mut is_json = false;
|
let mut is_json = false;
|
||||||
|
|
||||||
|
@ -749,11 +749,11 @@ pub fn pipe() -> Result<(Fd, Fd), Error> {
|
|||||||
///
|
///
|
||||||
/// Mostly useful to downcast trait objects (see RpcEnvironment).
|
/// Mostly useful to downcast trait objects (see RpcEnvironment).
|
||||||
pub trait AsAny {
|
pub trait AsAny {
|
||||||
fn as_any(&self) -> &Any;
|
fn as_any(&self) -> &dyn Any;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Any> AsAny for T {
|
impl<T: Any> AsAny for T {
|
||||||
fn as_any(&self) -> &Any { self }
|
fn as_any(&self) -> &dyn Any { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ impl <T: Clone> BroadcastData<T> {
|
|||||||
|
|
||||||
/// Broadcast future results to registered listeners
|
/// Broadcast future results to registered listeners
|
||||||
pub struct BroadcastFuture<T> {
|
pub struct BroadcastFuture<T> {
|
||||||
inner: Arc<Mutex<(BroadcastData<T>, Option<Box<Future<Item=T, Error=Error> + Send>>)>>,
|
inner: Arc<Mutex<(BroadcastData<T>, Option<Box<dyn Future<Item=T, Error=Error> + Send>>)>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <T: Clone + Send + 'static> BroadcastFuture<T> {
|
impl <T: Clone + Send + 'static> BroadcastFuture<T> {
|
||||||
@ -62,7 +62,7 @@ impl <T: Clone + Send + 'static> BroadcastFuture<T> {
|
|||||||
/// Create instance for specified source future.
|
/// Create instance for specified source future.
|
||||||
///
|
///
|
||||||
/// The result of the future is sent to all registered listeners.
|
/// The result of the future is sent to all registered listeners.
|
||||||
pub fn new(source: Box<Future<Item=T, Error=Error> + Send>) -> Self {
|
pub fn new(source: Box<dyn Future<Item=T, Error=Error> + Send>) -> Self {
|
||||||
Self { inner: Arc::new(Mutex::new((BroadcastData::new(), Some(source)))) }
|
Self { inner: Arc::new(Mutex::new((BroadcastData::new(), Some(source)))) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,12 +76,12 @@ impl <T: Clone + Send + 'static> BroadcastFuture<T> {
|
|||||||
(Self::new(test), tx)
|
(Self::new(test), tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn notify_listeners(inner: Arc<Mutex<(BroadcastData<T>, Option<Box<Future<Item=T, Error=Error> + Send>>)>>, result: Result<T, String>) {
|
fn notify_listeners(inner: Arc<Mutex<(BroadcastData<T>, Option<Box<dyn Future<Item=T, Error=Error> + Send>>)>>, result: Result<T, String>) {
|
||||||
let mut data = inner.lock().unwrap();
|
let mut data = inner.lock().unwrap();
|
||||||
data.0.notify_listeners(result);
|
data.0.notify_listeners(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spawn(inner: Arc<Mutex<(BroadcastData<T>, Option<Box<Future<Item=T, Error=Error> + Send>>)>>) -> impl Future<Item=T, Error=Error> {
|
fn spawn(inner: Arc<Mutex<(BroadcastData<T>, Option<Box<dyn Future<Item=T, Error=Error> + Send>>)>>) -> impl Future<Item=T, Error=Error> {
|
||||||
|
|
||||||
let mut data = inner.lock().unwrap();
|
let mut data = inner.lock().unwrap();
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ impl ReadDirEntry {
|
|||||||
// This is simply a wrapper with a shorter type name mapping nix::Error to failure::Error.
|
// 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()`.
|
/// Wrapper over a pair of `nix::dir::Dir` and `nix::dir::Iter`, returned by `read_subdir()`.
|
||||||
pub struct ReadDir {
|
pub struct ReadDir {
|
||||||
iter: Tied<Dir, Iterator<Item = nix::Result<dir::Entry>> + Send>,
|
iter: Tied<Dir, dyn Iterator<Item = nix::Result<dir::Entry>> + Send>,
|
||||||
dir_fd: RawFd,
|
dir_fd: RawFd,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,8 @@ pub fn read_subdir<P: ?Sized + nix::NixPath>(dirfd: RawFd, path: &P) -> Result<R
|
|||||||
let dir = Dir::openat(dirfd, path, OFlag::O_RDONLY, Mode::empty())?;
|
let dir = Dir::openat(dirfd, path, OFlag::O_RDONLY, Mode::empty())?;
|
||||||
let fd = dir.as_raw_fd();
|
let fd = dir.as_raw_fd();
|
||||||
let iter = Tied::new(dir, |dir| {
|
let iter = Tied::new(dir, |dir| {
|
||||||
Box::new(unsafe { (*dir).iter() }) as Box<Iterator<Item = nix::Result<dir::Entry>> + Send>
|
Box::new(unsafe { (*dir).iter() })
|
||||||
|
as Box<dyn Iterator<Item = nix::Result<dir::Entry>> + Send>
|
||||||
});
|
});
|
||||||
Ok(ReadDir { iter, dir_fd: fd })
|
Ok(ReadDir { iter, dir_fd: fd })
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user