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

#122 in Filesystem

Download history 5563/week @ 2024-09-26 4788/week @ 2024-10-03 5165/week @ 2024-10-10 5503/week @ 2024-10-17 3945/week @ 2024-10-24 5010/week @ 2024-10-31 4857/week @ 2024-11-07 3789/week @ 2024-11-14 3994/week @ 2024-11-21 3349/week @ 2024-11-28 4924/week @ 2024-12-05 4618/week @ 2024-12-12 3393/week @ 2024-12-19 3150/week @ 2024-12-26 4769/week @ 2025-01-02 4803/week @ 2025-01-09

16,967 downloads per month
Used in 20 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

~435–590KB
~11K SLoC