fudisks 0.1.0

High-level wrapper for the udisks2 crate
Documentation
  • Coverage
  • 20.88%
    19 out of 91 items documented0 out of 25 items with examples
  • Size
  • Source code size: 62.39 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.44 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 7m 26s Average build duration of successful builds.
  • all releases: 7m 26s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • MoAlyousef/fudisks
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • MoAlyousef

fudisks

A high-level wrapper around the udisks2 crate. A work in progress!

Example: List Devices

cargo run --example list_devices

Example: Format a Partition (DANGEROUS)

ALLOW_DESTRUCTIVE=1 cargo run --example format_partition -- <udisks_object_path>

Quick Start

use fudisks::{Udisks, FormatOptions, JobEvent};
use futures_util::StreamExt;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let ud = Udisks::connect_system().await?;

    // Choose a partition object path from list_devices output
    let part = "/org/freedesktop/UDisks2/block_devices/sdb1";

    let opts = FormatOptions::Exfat { label: Some("USB".into()), cluster_size: None, quick: true };
    let handle = ud.format_partition(part, &opts).await?;

    let mut stream = handle.watch();
    while let Some(evt) = stream.next().await {
        match evt {
            JobEvent::Percent(p) => println!("{p:.1}%"),
            JobEvent::RateBytesPerSec(r) => println!("{r} B/s"),
            JobEvent::Completed(res) => match res {
                Ok(()) => break,
                Err(e) => { eprintln!("error: {}", e); return Err(e.into()); }
            }
        }
    }
    Ok(())
}

Format a whole disk using GPT (default) or DOS/MBR (DANGEROUS):

ALLOW_DESTRUCTIVE=1 cargo run --example format_disk -- <disk_object_path> gpt
ALLOW_DESTRUCTIVE=1 cargo run --example format_disk -- <disk_object_path> dos