1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
use std::collections::HashMap;
use zbus::Connection;
#[tokio::main]
async fn main() -> udisks2::Result<()> {
gettextrs::setlocale(gettextrs::LocaleCategory::LcAll, "de_DE.UTF-8");
gettextrs::textdomain(GETTEXT_PACKAGE).expect("Failed to set textdomain");
let client = udisks2::Client::new().await?;
let version = client.manager().version().await?;
println!("Version: {}", version);
let object = client
.object("/org/freedesktop/UDisks2/block_devices/sda")
.expect("No sda device found");
let block = object.block().await?;
let drive = client.drive_for_block(&block).await?;
println!(
"Size: {}",
client.size_for_display(drive.size().await?, true, true)
);
println!("Block: {}", block.inner().path());
let drive =
client.object("/org/freedesktop/UDisks2/drives/SanDisk_SSD_PLUS_1000GB_1926FP462112")?;
println!(
"Drive: {:?}",
drive.drive().await.unwrap().can_power_off().await
);
println!("{:?}", block.device().await);
let swap = client.object("/org/freedesktop/UDisks2/block_devices/zram0")?;
println!("Swap: {:?}", swap.swapspace().await?.active().await?);
//println!(
// "Object: {:?}",
// client.object(drive.drive().await?.inner().path().to_owned())
//);
const GETTEXT_PACKAGE: &str = "udisks2";
//
println!(
"{}",
gettextrs::dgettext(GETTEXT_PACKAGE, "Mount a filesystem on a system device")
);
// println!("{:?}", client.partition_table_type_for_display("apm"));
// println!(
// "{:?}",
// client.job_description_from_operation("md-raid-creates")
// );
// println!("{:?}", block.symlinks().await);
let fs = client
.object("/org/freedesktop/UDisks2/block_devices/sdb2")
.expect("No sda device found")
.filesystem()
.await?;
println!("MountPoints: {:?}", fs.mount_points().await?);
let connection = zbus::Connection::session().await?;
let job = udisks2::job::JobProxy::new(&connection).await.unwrap();
dbg!(&job.rate().await);
Ok(())
}
|