23 releases (6 stable)

4.1.0 Mar 16, 2025
4.0.0 Sep 13, 2024
4.0.0-rc.3 Apr 21, 2024
4.0.0-rc.1 Nov 18, 2023
0.1.7 Apr 24, 2017

#49 in Filesystem

Download history 7350/week @ 2025-11-20 6346/week @ 2025-11-27 6107/week @ 2025-12-04 6798/week @ 2025-12-11 6640/week @ 2025-12-18 5581/week @ 2025-12-25 7625/week @ 2026-01-01 8137/week @ 2026-01-08 8623/week @ 2026-01-15 8837/week @ 2026-01-22 8240/week @ 2026-01-29 8086/week @ 2026-02-05 7211/week @ 2026-02-12 8258/week @ 2026-02-19 14345/week @ 2026-02-26 13269/week @ 2026-03-05

44,307 downloads per month
Used in 27 crates (22 directly)

MIT license

115KB
2K SLoC

gpt

crates.io minimum rust 1.65 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 std::error::Error;

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

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

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

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

    Ok(())
}

Dependencies

~0.4–2.2MB
~21K SLoC