988d575dbb
The type is a real enum. All are API types and implement Display and FromStr. The ordering is the same as it is in pbs-datastore. Also, they are now flattened into a few structs instead of being copied manually. Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
48 lines
1.0 KiB
Rust
48 lines
1.0 KiB
Rust
use anyhow::Error;
|
|
|
|
use pbs_api_types::{Authid, BackupType};
|
|
use pbs_client::{BackupWriter, HttpClient, HttpClientOptions};
|
|
|
|
async fn upload_speed() -> Result<f64, Error> {
|
|
let host = "localhost";
|
|
let datastore = "store2";
|
|
|
|
let auth_id = Authid::root_auth_id();
|
|
|
|
let options = HttpClientOptions::default()
|
|
.interactive(true)
|
|
.ticket_cache(true);
|
|
|
|
let client = HttpClient::new(host, 8007, auth_id, options)?;
|
|
|
|
let backup_time = proxmox_time::epoch_i64();
|
|
|
|
let client = BackupWriter::start(
|
|
client,
|
|
None,
|
|
datastore,
|
|
BackupType::Host,
|
|
"speedtest",
|
|
backup_time,
|
|
false,
|
|
true,
|
|
)
|
|
.await?;
|
|
|
|
println!("start upload speed test");
|
|
let res = client.upload_speedtest(true).await?;
|
|
|
|
Ok(res)
|
|
}
|
|
|
|
fn main() {
|
|
match proxmox_async::runtime::main(upload_speed()) {
|
|
Ok(mbs) => {
|
|
println!("average upload speed: {} MB/s", mbs);
|
|
}
|
|
Err(err) => {
|
|
eprintln!("ERROR: {}", err);
|
|
}
|
|
}
|
|
}
|