diff --git a/src/bin/upload-speed.rs b/src/bin/upload-speed.rs index b07615cb..fe20b524 100644 --- a/src/bin/upload-speed.rs +++ b/src/bin/upload-speed.rs @@ -1,9 +1,8 @@ use failure::*; -use futures::*; use proxmox_backup::client::*; -fn upload_speed() -> Result { +async fn upload_speed() -> Result { let host = "localhost"; let datastore = "store2"; @@ -14,28 +13,22 @@ fn upload_speed() -> Result { let backup_time = chrono::Utc::now(); - let client = client.start_backup(datastore, "host", "speedtest", backup_time, false).wait()?; + let client = client.start_backup(datastore, "host", "speedtest", backup_time, false).await?; println!("start upload speed test"); - let res = client.upload_speedtest().wait()?; + let res = client.upload_speedtest().await?; Ok(res) } -fn main() { - - let mut rt = tokio::runtime::Runtime::new().unwrap(); - - // should be rt.block_on_all, but this block forever in release builds - let _ = rt.block_on(futures::future::lazy(move || -> Result<(), ()> { - match upload_speed() { - Ok(mbs) => { - println!("average upload speed: {} MB/s", mbs); - } - Err(err) => { - eprintln!("ERROR: {}", err); - } +#[tokio::main] +async fn main() { + match upload_speed().await { + Ok(mbs) => { + println!("average upload speed: {} MB/s", mbs); } - Ok(()) - })); + Err(err) => { + eprintln!("ERROR: {}", err); + } + } }