22 releases (5 stable)

4.0.0 Sep 13, 2024
4.0.0-rc.3 Apr 21, 2024
4.0.0-rc.1 Nov 18, 2023
3.1.0 Jul 4, 2023
0.1.7 Apr 24, 2017

#52 in Filesystem

Download history 6128/week @ 2024-07-30 6430/week @ 2024-08-06 5107/week @ 2024-08-13 5357/week @ 2024-08-20 5769/week @ 2024-08-27 5205/week @ 2024-09-03 6020/week @ 2024-09-10 4975/week @ 2024-09-17 5509/week @ 2024-09-24 4553/week @ 2024-10-01 5100/week @ 2024-10-08 5610/week @ 2024-10-15 4536/week @ 2024-10-22 4339/week @ 2024-10-29 5553/week @ 2024-11-05 3795/week @ 2024-11-12

19,030 downloads per month
Used in 19 crates (15 directly)

MIT license

115KB
2K SLoC

gpt

crates.io minimum rust 1.63 Documentation

A pure-Rust library to work with GPT partition tables.

gpt provides support for manipulating (R/W) GPT headers and partition tables. It supports any that implements the Read + Write + Seek + Debug traits.

Example

use gpt;

use std::io;

fn main() {
    // Inspect disk image, handling errors.
    if let Err(e) = run() {
        eprintln!("Failed to inspect image: {}", e);
        std::process::exit(1)
    }
}

fn run() -> io::Result<()> {
    // First parameter is target disk image (optional, default: fixtures sample)
    let sample = "tests/fixtures/gpt-linux-disk-01.img".to_string();
    let input = std::env::args().nth(1).unwrap_or(sample);

    // Open disk image.
    let diskpath = std::path::Path::new(&input);
    let cfg = gpt::GptConfig::new().writable(false);
    let disk = cfg.open(diskpath)?;

    // Print GPT layout.
    println!("Disk (primary) header: {:#?}", disk.primary_header());
    println!("Partition layout: {:#?}", disk.partitions());

    Ok(())
}

Dependencies

~425–580KB
~11K SLoC