src/bin/proxmox-backup-client.rs: use async fn

This commit is contained in:
Dietmar Maurer 2019-12-19 11:20:59 +01:00
parent f74a03da1f
commit d6c4a1198a
1 changed files with 35 additions and 47 deletions

View File

@ -2176,9 +2176,8 @@ fn catalog_mgmt_cli() -> CliCommandMap {
} }
)] )]
/// List running server tasks for this repo user /// List running server tasks for this repo user
fn task_list(param: Value) -> Result<Value, Error> { async fn task_list(param: Value) -> Result<Value, Error> {
async_main(async {
let output_format = param["output-format"].as_str().unwrap_or("text").to_owned(); let output_format = param["output-format"].as_str().unwrap_or("text").to_owned();
let repo = extract_repository_from_value(&param)?; let repo = extract_repository_from_value(&param)?;
let client = HttpClient::new(repo.host(), repo.user(), None)?; let client = HttpClient::new(repo.host(), repo.user(), None)?;
@ -2208,9 +2207,6 @@ fn task_list(param: Value) -> Result<Value, Error> {
format_and_print_result(data, &output_format); format_and_print_result(data, &output_format);
} }
Ok::<_, Error>(())
})?;
Ok(Value::Null) Ok(Value::Null)
} }
@ -2228,9 +2224,8 @@ fn task_list(param: Value) -> Result<Value, Error> {
} }
)] )]
/// Display the task log. /// Display the task log.
fn task_log(param: Value) -> Result<Value, Error> { async fn task_log(param: Value) -> Result<Value, Error> {
async_main(async {
let repo = extract_repository_from_value(&param)?; let repo = extract_repository_from_value(&param)?;
let upid = tools::required_string_param(&param, "upid")?; let upid = tools::required_string_param(&param, "upid")?;
@ -2238,9 +2233,6 @@ fn task_log(param: Value) -> Result<Value, Error> {
display_task_log(client, upid, true).await?; display_task_log(client, upid, true).await?;
Ok::<_, Error>(())
})?;
Ok(Value::Null) Ok(Value::Null)
} }
@ -2258,9 +2250,8 @@ fn task_log(param: Value) -> Result<Value, Error> {
} }
)] )]
/// Try to stop a specific task. /// Try to stop a specific task.
fn task_stop(param: Value) -> Result<Value, Error> { async fn task_stop(param: Value) -> Result<Value, Error> {
async_main(async {
let repo = extract_repository_from_value(&param)?; let repo = extract_repository_from_value(&param)?;
let upid_str = tools::required_string_param(&param, "upid")?; let upid_str = tools::required_string_param(&param, "upid")?;
@ -2269,9 +2260,6 @@ fn task_stop(param: Value) -> Result<Value, Error> {
let path = format!("api2/json/nodes/localhost/tasks/{}", upid_str); let path = format!("api2/json/nodes/localhost/tasks/{}", upid_str);
let _ = client.delete(&path, None).await?; let _ = client.delete(&path, None).await?;
Ok::<_, Error>(())
})?;
Ok(Value::Null) Ok(Value::Null)
} }