21 releases (4 stable)

4.0.0-rc.3 Apr 21, 2024
4.0.0-rc.1 Nov 18, 2023
3.1.0 Jul 4, 2023
3.0.0 Oct 15, 2021
0.1.7 Apr 24, 2017

#34 in Filesystem

Download history 4580/week @ 2024-01-12 4951/week @ 2024-01-19 3793/week @ 2024-01-26 3036/week @ 2024-02-02 3830/week @ 2024-02-09 3672/week @ 2024-02-16 4538/week @ 2024-02-23 3880/week @ 2024-03-01 4606/week @ 2024-03-08 4483/week @ 2024-03-15 4944/week @ 2024-03-22 5232/week @ 2024-03-29 4896/week @ 2024-04-05 3390/week @ 2024-04-12 4488/week @ 2024-04-19 3979/week @ 2024-04-26

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

MIT license

110KB
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–570KB
~11K SLoC